Creates an Pdftohtml driver.

@param LoggerInterface     $logger
@param array|Configuration $configuration

@return Pdftohtml
10746
public static function create(LoggerInterface $logger = null, $configuration = array())
    {
        if (!$configuration instanceof ConfigurationInterface) {
            $configuration = new Configuration($configuration);
        }

        $binaries = $configuration->get('pdftohtml.binaries', 'pdftohtml');

        if (!$configuration->has('timeout')) {
            $configuration->set('timeout', 60);
        }

        try {
            return static::load($binaries, $logger, $configuration);
        } catch (BinaryDriverExecutableNotFound $e) {
            throw new ExecutableNotFoundException('Unable to load pdftohtml', $e->getCode(), $e);
        }
    }
413236
public function addLogger(LoggerInterface $logger)
    {
        if ($this->isLoggerLoaded() && !($this->logger instanceof NullLogger)) {
            $logger = new LoggerAggregator([$logger, $this->logger]);
        }
        $this->logger = $logger;
        return $logger;
    }
334808
public function setLogger(
        \Psr\Log\LoggerInterface $logger = null,
        $messageFormat = \GuzzleHttp\MessageFormatter::CLF
    ) {
        if ($logger === null) {
            $handler = new \Monolog\Handler\ErrorLogHandler(\Monolog\Handler\ErrorLogHandler::SAPI);
            $handler->setFormatter(new \Monolog\Formatter\LineFormatter('%message%'));
            $logger = new \Monolog\Logger('HTTP Log', [$handler]);
        }

        $formatter = new \GuzzleHttp\MessageFormatter($messageFormat);

        $handler = \GuzzleHttp\Middleware::log($logger, $formatter);
        $this->logger = $handler;

        $handlerStack = $this->getConfig('handler');
        $this->setLogHandler($handlerStack, $handler);

        return $this;
    }
1225635
public function getBundler(Logger $logger)
    {
        $bundlerName = 'complete';
        if (isset($this->package['extra']['phar']['bundler'])) {
            $bundlerName = $this->package['extra']['phar']['bundler'];
        }

        if ($bundlerName === 'composer') {
            return new ExplicitBundler($this, $logger);
        } elseif ($bundlerName === 'complete') {
            return new CompleteBundler($this, $logger);
        } else {
            $logger->log('Invalid bundler "' . $bundlerName . '" specified in package "' . $this->getName() . '", will fall back to "complete" bundler');
            return new CompleteBundler($this, $logger);
        }
    }
1251355
public function createDocumentManager($connection,$config)
    {
        $dbConn = new Connection($connection);
        $dm = DocumentManager::create($dbConn,$config);
        return $dm;
    }
433704
private function applyDecorators(LoggerInterface $logger, array $config)
    {
        foreach ($this->decorators as $configKey => $decoratorClassName) {
            if (!isset($config[$configKey])) {
                continue;
            }
            if (!class_exists($decoratorClassName)) {
                throw new \RuntimeException('Decorator class not found: ' . $decoratorClassName);
            }
            if (!is_subclass_of($decoratorClassName, '\Phlib\Logger\Decorator\AbstractDecorator')) {
                throw new \RuntimeException('Decorator class invalid: ' . $decoratorClassName);
            }
            /** @var \Phlib\Logger\Decorator\AbstractDecorator $logger */
            $logger = new $decoratorClassName($logger, $config[$configKey]);
        }

        return $logger;
    }
222518
public function fromArray(LoggerInterface $logger, array $data, string $useragent): BrowserInterface
    {
        $name  = array_key_exists('name', $data) ? $data['name'] : null;
        $modus = array_key_exists('modus', $data) ? $data['modus'] : null;
        $bits  = (new \BrowserDetector\Bits\Browser())->getBits($useragent);

        $type = new Unknown();
        if (array_key_exists('type', $data)) {
            try {
                $type = $this->typeLoader->load((string) $data['type']);
            } catch (NotFoundException $e) {
                $logger->info($e);
            }
        }

        $version      = $this->getVersion($data, $useragent);
        $manufacturer = $this->getCompany($logger, $data, $useragent, 'manufacturer');

        return new Browser($name, $manufacturer, $version, $type, $bits, $modus);
    }
805944
public function createCollection(LoggerInterface $logger, string $buildFolder, ?string $file = null) : WriterCollection
    {
        $writerCollection = new WriterCollection();
        $propertyHolder   = new PropertyHolder();

        if (null === $file) {
            $file = $buildFolder . '/full_php_browscap.ini';
        }

        $fullFilter    = new FullFilter($propertyHolder);
        $fullPhpWriter = new IniWriter($file, $logger);
        $formatter     = new PhpFormatter($propertyHolder);
        $fullPhpWriter->setFormatter($formatter);
        $fullPhpWriter->setFilter($fullFilter);

        $writerCollection->addWriter($fullPhpWriter);

        return $writerCollection;
    }
949787
public static function createWithBuilder(
        HandlerBuilderInterface $builder,
        FormatterRegistryInterface $formatterRegistry,
        $debug = false
    ) {
        $handler = $builder->buildHandler();
        $docGenerator = new DocGenerator($builder->buildDocExtractor(), $formatterRegistry);

        return new static($handler, $docGenerator, $debug);
    }
1362760
public function getLog(string $logger = 'default'): LoggerInterface
    {
        if (!isset($this->loggers[$logger])) {
            if ($logger === 'default') {
                if (!isset($this->implicit['logger'])) {
                    throw new \RuntimeException('The default logger was not set');
                }
                $this->loggers[$logger] = $this->implicit['logger'];
            } else {
                $this->loggers[$logger] = $this->getCollector()->getLogger($logger);
            }
        }

        return $this->loggers[$logger];
    }
596810
public function fromArray(LoggerInterface $logger, array $data, string $useragent): EngineInterface
    {
        $name = array_key_exists('name', $data) ? $data['name'] : null;

        $version      = $this->getVersion($data, $useragent);
        $manufacturer = $this->getCompany($logger, $data, $useragent, 'manufacturer');

        return new Engine($name, $manufacturer, $version);
    }
766157
protected function createLogDriver()
    {
        $logger = $this->app->make(LoggerInterface::class);

        if ($logger instanceof LogManager) {
            $logger = $logger->channel($this->app['config']['mail.log_channel']);
        }

        return new LogTransport($logger);
    }
1192454
public function renderer($config = null)
    {
        if ($config !== null) {
            $this->_renderer = new CakePdf($config);
        }

        return $this->_renderer;
    }
882480
public function fromArray(LoggerInterface $logger, array $data): DisplayInterface
    {
        $width  = array_key_exists('width', $data) ? $data['width'] : null;
        $height = array_key_exists('height', $data) ? $data['height'] : null;
        $touch  = array_key_exists('touch', $data) ? $data['touch'] : null;
        $size   = array_key_exists('size', $data) ? $data['size'] : null;

        try {
            $type = $this->typeLoader->loadByDiemsions($height, $width);
        } catch (NotFoundException $e) {
            $logger->info($e);

            $type = new Unknown();
        }

        return new Display($touch, $type, $size);
    }
1070638
public function handle(string $content, array $configuration): string
    {
        $request = $this->requestStack->getCurrentRequest();

        $request->attributes->set('data', $this->cObj->data);
        $request->attributes->set('_controller', $configuration['controller']);

        $request->headers->set('X-Php-Ob-Level', \ob_get_level());

        // request
        $event = new GetResponseEvent($this->kernel, $request, HttpKernel::SUB_REQUEST);
        $this->dispatcher->dispatch(KernelEvents::REQUEST, $event);

        if ($event->hasResponse()) {
            return $this->filterResponse($event->getResponse(), $request, HttpKernel::SUB_REQUEST);
        }

        // load controller
        $controller = $this->resolver->getController($request);
        if (false === $controller) {
            throw new NotFoundHttpException(\sprintf('Unable to find the controller "%s". The content element is wrongly configured.', $request->attributes->get('_controller', $configuration['controller'])));
        }

        $event = new FilterControllerEvent($this->kernel, $controller, $request, HttpKernel::SUB_REQUEST);
        $this->dispatcher->dispatch(KernelEvents::CONTROLLER, $event);
        $controller = $event->getController();

        // controller arguments
        $arguments = $this->argumentResolver->getArguments($request, $controller);

        $event = new FilterControllerArgumentsEvent($this->kernel, $controller, $arguments, $request, HttpKernel::SUB_REQUEST);
        $this->dispatcher->dispatch(KernelEvents::CONTROLLER_ARGUMENTS, $event);
        $controller = $event->getController();
        $arguments = $event->getArguments();

        // call controller
        try {
            $response = $controller(...$arguments);
        } catch (NotFoundHttpException $e) {
            $psrResponse = $this->errorController->pageNotFoundAction(
                $this->psrHttpFactory->createRequest($request),
                $e->getMessage()
            );

            throw new ImmediateResponseException($psrResponse);
        }

        // view
        if (!$response instanceof Response) {
            $event = new GetResponseForControllerResultEvent($this->kernel, $request, HttpKernel::SUB_REQUEST, $response);
            $this->dispatcher->dispatch(KernelEvents::VIEW, $event);

            if ($event->hasResponse()) {
                $response = $event->getResponse();
            } else {
                $msg = \sprintf('The controller must return a "Symfony\Component\HttpFoundation\Response" object but it returned %s.', $this->varToString($response));

                // the user may have forgotten to return something
                if (null === $response) {
                    $msg .= ' Did you forget to add a return statement somewhere in your controller?';
                }

                throw new ControllerDoesNotReturnResponseException($msg, $controller, __FILE__, __LINE__ - 23);
            }
        }

        return $this->filterResponse($response, $request, HttpKernel::SUB_REQUEST);
    }
287493
protected function buildCodeFromSql(Configuration $configuration, array $sql): string
    {
        $currentPlatform = $configuration->getConnection()->getDatabasePlatform()->getName();
        $code = [];
        foreach ($sql as $query) {
            if (stripos($query, $configuration->getMigrationsTableName()) !== false) {
                continue;
            }
            $code[] = sprintf('$this->addSql(%s);', var_export($query, true));
        }

        if (!empty($code)) {
            array_unshift(
                $code,
                sprintf(
                    '$this->abortIf($this->connection->getDatabasePlatform()->getName() !== %s, %s);',
                    var_export($currentPlatform, true),
                    var_export(sprintf('Migration can only be executed safely on "%s".', $currentPlatform), true)
                ),
                ''
            );
        }

        return implode(chr(10), $code);
    }
182053
protected function prepareHandler(HandlerInterface $handler, array $config = [])
    {
        if (! isset($config['formatter'])) {
            $handler->setFormatter($this->formatter());
        } elseif ($config['formatter'] !== 'default') {
            $handler->setFormatter($this->app->make($config['formatter'], $config['formatter_with'] ?? []));
        }

        return $handler;
    }