Example #1
0
 public function testViewGlobals()
 {
     $dispatcher = m::mock('Illuminate\\Events\\Dispatcher');
     $dispatcher->shouldReceive('fire')->andReturn(true);
     $environment = new Environment(m::mock('Illuminate\\View\\Engines\\EngineResolver'), m::mock('Illuminate\\View\\ViewFinderInterface'), $dispatcher);
     $engine = $this->getEngine();
     $view = new View($environment, $engine, 'base.twig', __DIR__);
     $view->render();
     // Grab globals set on the Twig environment
     $globals = $engine->getTwig()->getGlobals();
     $this->assertArrayHasKey('__env', $globals);
     $this->assertInstanceOf('Illuminate\\View\\Environment', $globals['__env']);
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function display(array $context, array $blocks = array())
 {
     $template_name = $this->getTemplateName();
     // Deal with view composers
     if (App::make('events')->hasListeners('composing: ' . $template_name)) {
         // Create dummy view object to hold the data from the event we are about to fire
         $env = App::make('view');
         $view = new View($env, $env->getEngineResolver()->resolve('twig'), null, null, array());
         // Fire composer event
         App::make('events')->fire('composing: ' . $template_name, array($view));
         // Merge composer data with context passed in
         $context = array_merge($view->getData(), $context);
     }
     parent::display($context, $blocks);
 }