コード例 #1
0
 protected function createPipeline($namespace, $name, Configuration $config)
 {
     $pipeline = new Pipeline($namespace, $name, new MediaType($config->getString('type')));
     $processor = new CssUrlProcessor(['css']);
     $processor->setResourcePublisher($this->publisher);
     $pipeline->addProcessor($processor);
     if ($config->has('encoding')) {
         $pipeline->setEncoding($config->getString('encoding'));
     }
     if ($config->has('ttl')) {
         $pipeline->setTtl($config->getInteger('ttl'));
     }
     return $this->populateSources($pipeline, $config->getConfig('sources'));
 }
コード例 #2
0
 public function create(Configuration $config)
 {
     $cachePath = $config->getString('cachePath', NULL);
     $createFolder = $config->getBoolean('createFolder', false);
     if ($cachePath !== NULL) {
         if (!is_dir($cachePath)) {
             if (!$createFolder) {
                 throw new \RuntimeException(sprintf('Cache directory not found: "%s"', $cachePath));
             }
             $cachePath = Filesystem::createDirectory($cachePath);
         }
         if (!is_readable($cachePath)) {
             throw new \RuntimeException(sprintf('Cache directory not readable: "%s"', $cachePath));
         }
         if (!is_writable($cachePath)) {
             throw new \RuntimeException(sprintf('Cache directory not writable: "%s"', $cachePath));
         }
     }
     return new ExpressViewFactory($cachePath, $this->logger);
 }
コード例 #3
0
 public function createProcessEngine(Configuration $config, LoggerInterface $logger = NULL)
 {
     $conn = $this->connectionManager->getConnection($config->getString('connection', 'default'));
     $transactional = $config->getBoolean('transactional', true);
     $dispatcher = $this->container->get(EventDispatcher::class);
     $engine = new ProcessEngine($conn, $dispatcher, $this->factory, $transactional);
     $engine->setDelegateTaskFactory($this->taskFactory);
     $engine->registerExecutionInterceptor(new ScopeExecutionInterceptor($this->scope));
     $engine->setLogger($logger);
     $executor = new JobExecutor($engine, $this->scheduler);
     $this->container->eachMarked(function (JobHandler $handler, BindingInterface $binding) use($executor) {
         $executor->registerJobHandler($this->container->getBound($binding));
     });
     $engine->setJobExecutor($executor);
     $dispatcher->connect(function (AbstractProcessEvent $event) {
         $this->scope->enterContext($event->execution);
     });
     $dispatcher->connect(function (TaskExecutedEvent $event) {
         $query = $event->engine->getRuntimeService()->createExecutionQuery();
         $query->executionId($event->execution->getExecutionId());
         $definition = $query->findOne()->getProcessDefinition();
         $processKey = $definition->getKey();
         $taskKey = $event->execution->getActivityId();
         $this->container->eachMarked(function (TaskHandler $handler, BindingInterface $binding) use($event, $taskKey, $processKey) {
             if ($taskKey == $handler->taskKey) {
                 if ($handler->processKey === NULL || $handler->processKey == $processKey) {
                     $task = $this->container->getBound($binding);
                     if (!$task instanceof TaskHandlerInterface) {
                         throw new \RuntimeException('Invalid task handler implementation: ' . get_class($task));
                     }
                     $task->executeTask($event->execution);
                 }
             }
         });
     });
     return $engine;
 }
コード例 #4
0
ファイル: Komponent.php プロジェクト: koolkode/http-komponent
 public function createSendFileFilter(Configuration $config)
 {
     switch ($config->getString('transport', NULL)) {
         case 'apache':
         case 'lighttpd':
             $transport = SendFileFilter::TRANSPORT_SEND_FILE;
             break;
         case 'nginx':
             $transport = SendFileFilter::TRANSPORT_ACCEL_REDIRECT;
             break;
         case 'lighttpd':
             $transport = SendFileFilter::TRANSPORT_LIGHTTPD;
             break;
         default:
             $transport = SendFileFilter::TRANSPORT_NONE;
     }
     return new SendFileFilter($transport);
 }