Exemplo n.º 1
0
 /**
  * @param ViewLocator       $locator
  * @param ViewManager       $manager
  * @param ConsoleDispatcher $dispatcher
  */
 public function perform(ViewLocator $locator, ViewManager $manager, ConsoleDispatcher $dispatcher)
 {
     //To clean up cache
     $dispatcher->command('views:reset', [], $this->output);
     if ($this->isVerbosity()) {
         $this->write("\n");
     }
     /**
      * @var FormatterHelper $formatter
      */
     $formatter = $this->getHelper('formatter');
     foreach ($locator->getNamespaces() as $namespace) {
         $this->isVerbosity() && $this->writeln("Compiling views in namespace '<comment>{$namespace}</comment>'.");
         foreach ($locator->namespaceViews($namespace) as $view => $engine) {
             if ($this->isVerbosity()) {
                 $this->write($formatter->formatSection("{$namespace}:{$engine}", $view . ", ", 'fg=cyan'));
             }
             $benchmark = $this->benchmark('compile');
             try {
                 //Compilation
                 $manager->engine($engine)->compile("{$namespace}:{$view}", true);
                 $this->isVerbosity() && $this->write("<info>ok</info>");
             } catch (\Exception $exception) {
                 if ($this->isVerbosity()) {
                     $this->write("<fg=red>error: {$exception->getMessage()}</fg=red>");
                 }
             } finally {
                 $elapsed = number_format($this->benchmark($benchmark) * 1000);
                 if ($this->isVerbosity()) {
                     $this->writeln(" <comment>[{$elapsed} ms]</comment> ");
                 }
             }
         }
     }
     $this->writeln("<info>View cache was successfully generated.</info>");
 }
Exemplo n.º 2
0
 /**
  * @param ViewManager $views
  * @return  \Twig_Environment
  */
 public function twig(ViewManager $views)
 {
     return $views->engine('twig')->twig();
 }