상속: extends Symfony\Component\Console\Application
예제 #1
0
 public function register(Carew $carew)
 {
     $container = $carew->getContainer();
     $this->registerConfig($container);
     $this->registerEventDispatcher($container);
     $this->registerTwig($container);
     $container['builder'] = $container->share(function ($container) {
         return new Builder($container['processor'], $container['config'], $container['twig'], $container['filesystem'], $container['finder']);
     });
     $container['processor'] = $container->share(function ($container) {
         return new Processor($container['event_dispatcher'], $container['filesystem']);
     });
     $container['helper.path'] = $container->share(function ($container) {
         return new Path();
     });
     $container['helper.inflector'] = $container->share(function ($container) {
         return new Inflector();
     });
     $container['filesystem'] = $container->share(function ($container) {
         return new Filesystem();
     });
     $container['finder'] = function ($container) {
         return new Finder();
     };
 }
 public function register(Carew $carew)
 {
     $config = $carew->getContainer()->offsetGet('config');
     $maxPerPage = 10;
     if (isset($config['pagination']) && isset($config['pagination']['max_per_page'])) {
         $maxPerPage = $config['pagination']['max_per_page'];
         if (!is_int($maxPerPage)) {
             throw new \InvalidArgumentException('The pagination:max_per_page is not an int in your config.yml');
         }
     }
     $carew->getEventDispatcher()->addSubscriber(new PaginationListener($carew->getContainer()->offsetGet('twig'), $maxPerPage));
 }
예제 #3
0
 public function register(Carew $carew)
 {
     $container = $carew->getContainer();
     $config = $container['config']['less'];
     foreach ($container['themes'] as $theme) {
         if (is_file($theme . '/' . $config['input'])) {
             $input = $theme . '/' . $config['input'];
             break;
         }
     }
     $eventDispatcher = $carew->getEventDispatcher()->addSubscriber(new LessListener(new lessc(), $container['filesystem'], $input, $config['output']));
 }
예제 #4
0
 /**
  * @param Carew $carew
  */
 public function register(Carew $carew)
 {
     $container = $carew->getContainer();
     $registry = new AuthorRegistry();
     $eventDispatcher = $carew->getEventDispatcher();
     $config = $container->offsetGet('config');
     if (isset($config['authors'])) {
         foreach ($config['authors'] as $handle => $attributes) {
             $registry->addAuthor(new Author($handle, $attributes));
         }
     }
     $eventDispatcher->addSubscriber(new IndexesEventSubscriber($registry));
     $eventDispatcher->addSubscriber(new AuthorsEventSubscriber($registry, new AuthorIndexGenerator($container['base_dir'], new Finder()), $container->offsetGet('twig')));
 }
예제 #5
0
 public function register(Carew $carew)
 {
     $container = $carew->getContainer();
     if (!array_key_exists('aws', $container['config'])) {
         throw new \LogicException('The key "aws" does not exist in the config.yml file');
     }
     $awsConf = $container['config']['aws'];
     foreach (array('bucket', 'key', 'secret') as $key) {
         if (!array_key_exists($key, $awsConf)) {
             throw new \LogicException(sprintf('The key "%s" does not exist in the config.yml file', $key));
         }
     }
     $carew->register('deploy')->setDescription('Deploy the website')->setCode(function (InputInterface $input, OutputInterface $output) use($awsConf) {
         $client = S3Client::factory(array('key' => $awsConf['key'], 'secret' => $awsConf['secret']));
         $webDir = sprintf('%s/web', $input->getOption('base-dir'));
         if (!is_dir($webDir)) {
             throw new \InvalidArgumentException(sprintf('The web directory "%s" does not exist.', $webDir));
         }
         UploadSyncBuilder::getInstance()->setClient($client)->setBucket($awsConf['bucket'])->enableDebugOutput()->setAcl('public-read')->uploadFromDirectory($webDir)->build()->transfer();
     });
 }
 public function register(Carew $carew)
 {
     $container = $carew->getContainer();
     $baseDir = $container['base_dir'];
     $config = $container['config']['assetic'];
     $this->filterOptions = function (FilterInterface $filter, array $options) {
         foreach ($options as $option => $value) {
             $method = 'set' . ucfirst($option);
             $filter->{$method}($value);
         }
     };
     $this->fixBinPath = function ($binPath) use($baseDir) {
         if ('/' === $binPath[0]) {
             return $binPath;
         }
         return $baseDir . '/' . $binPath;
     };
     $listeners = array();
     if (isset($config['filters']['css'])) {
         $listeners[] = new EventListener\CssListener($container['finder'], $this->getCssFilter($config));
     }
     if (isset($config['filters']['js'])) {
         $listeners[] = new EventListener\JsListener($container['finder'], $this->getJsFilter($config));
     }
     if (isset($config['filters']['jpeg'])) {
         $listeners[] = new EventListener\JpegListener($container['finder'], $this->getJpegFilter($config));
     }
     if (isset($config['filters']['html'])) {
         $listeners[] = new EventListener\HtmlListener($container['finder'], $this->getHtmlFilter($config));
     }
     if (isset($config['filters']['xml'])) {
         $listeners[] = new EventListener\XmlListener($container['finder'], $this->getXmlFilter($config));
     }
     $eventDispatcher = $carew->getEventDispatcher();
     foreach ($listeners as $listener) {
         $eventDispatcher->addSubscriber($listener);
     }
 }
예제 #7
0
 public function register(Carew $carew)
 {
     $container = $carew->getContainer();
     $twig = $container['twig'];
     $twig->addFunction(new Twig_SimpleFunction('next_document', function (array $documents, Document $current) {
         $title = $current->getTitle();
         do {
             $document = current($documents);
             if ($document->getTitle() === $title) {
                 return next($documents);
             }
         } while (next($documents));
     }));
     $twig->addFunction(new Twig_SimpleFunction('previous_document', function (array $documents, Document $current) {
         $title = $current->getTitle();
         do {
             $document = current($documents);
             if ($document->getTitle() === $title) {
                 return prev($documents);
             }
         } while (next($documents));
     }));
 }
예제 #8
0
파일: BuildTest.php 프로젝트: carew/carew
 private function runApplication($fixturesPath)
 {
     $carew = new Carew();
     $carew->setAutoExit(false);
     $application = new ApplicationTester($carew);
     $input = array('command' => 'build', '--base-dir' => $fixturesPath, '--web-dir' => $fixturesPath . '/web', '--verbose' => true);
     $application->run($input);
     return $application;
 }
 /**
  * @param Carew $carew
  * @return Carew
  */
 private function setTwigEnvironment(Carew $carew)
 {
     $carew->getContainer()->expects($this->at(2))->method('offsetGet')->with('twig')->will($this->returnValue(new \Twig_Environment()));
     return $carew;
 }
 public function register(Carew $carew)
 {
     $container = $carew->getContainer();
     $eventDispatcher = $carew->getEventDispatcher()->addSubscriber(new FastNavEventSubscriber($container['config']));
 }
예제 #11
0
 public function register(Carew $carew)
 {
     $eventDispatcher = $carew->getEventDispatcher()->addSubscriber(new TocEventSubscriber());
 }
 public function register(Carew $carew)
 {
     $container = $carew->getContainer();
     $blogRoll = isset($container['config']['blogRoll']) ? $container['config']['blogRoll'] : array();
     $eventDispatcher = $carew->getEventDispatcher()->addSubscriber(new BlogRollEventSubscriber($container['twig'], $blogRoll));
 }
예제 #13
0
 public function register(Carew $carew)
 {
     $geshi = new Geshi();
     $eventDispatcher = $carew->getEventDispatcher()->addSubscriber(new HighlightEventSubscriber($geshi));
 }
 public function register(Carew $carew)
 {
     $container = $carew->getContainer();
     $eventDispatcher = $carew->getEventDispatcher()->addSubscriber(new TagListEventSubscriber($carew->getContainer()->offsetGet('twig'), $container['config']));
 }
예제 #15
0
 public function register(Carew $carew)
 {
     $dic = $carew->getContainer();
     $carew->addCommand(new UpdateCommand($carew->getContainer()->offsetGet('config')));
 }