Exemple #1
0
 /**
  * Attempts to find and load the given view
  *
  * @param string    $view
  * @param array     $data
  * @param null|bool $filter
  *
  * @return View
  *
  * @throws Exception\ViewNotFound If the given view cannot be found
  * @throws \DomainException       If a parser for the view cannot be found
  */
 public function forge($view, array $data = null, $filter = null)
 {
     if (!($file = $this->findView($view))) {
         throw new Exception\ViewNotFound('Could not locate view: ' . $view);
     }
     if ($filter === null) {
         $filter = $this->autoFilter;
     }
     $extension = pathinfo($file, PATHINFO_EXTENSION);
     if (!isset($this->parsers[$extension])) {
         throw new \DomainException('Could not find parser for extension: ' . $extension);
     }
     $parser = $this->parsers[$extension];
     $view = new View($this, $parser, $file, $filter);
     if ($data) {
         $view->set($data);
     }
     return $view;
 }
Exemple #2
0
 /**
  * @covers ::getData
  * @covers ::__construct
  */
 public function testGetData()
 {
     $this->view->set('baz', 'bat');
     $this->managerMock->shouldReceive('getData')->once()->andReturn(['foo' => 'bar']);
     $this->assertEquals(['baz' => 'bat', 'foo' => 'bar'], $this->view->getData());
 }