Create a new View object
public view ( string $viewName, string $viewType = 'html', array $config = [] ) : |
||
$viewName | string | The name of the view we're getting a View object for. |
$viewType | string | The type of the View object. By default it's "html". |
$config | array | Optional MVC configuration values for the View object. |
Résultat |
/** * Create a new View object * * @param string $viewName The name of the view we're getting a View object for. * @param string $viewType The type of the View object. By default it's "html". * @param array $config Optional MVC configuration values for the View object. * * @return View */ public function view($viewName, $viewType = 'html', array $config = array()) { try { return parent::view($viewName, $viewType, $config); } catch (ViewNotFound $e) { $magic = new Magic\ViewFactory($this->container); return $magic->make($viewName, $viewType, $config); } }
/** * @group SwitchFactory * @covers FOF30\Factory\SwitchFactory::view * @dataProvider SwitchFactoryDataprovider::getTestView */ public function testView($test, $check) { $msg = 'SwitchFactory::view %s - Case: ' . $check['case']; $platform = static::$container->platform; $platform::$template = 'fake_test_template'; $platform::$uriBase = 'www.example.com'; $platform::$isAdmin = $test['backend']; $factory = new SwitchFactory(static::$container); $result = $factory->view($test['view']); $this->assertEquals($check['result'], get_class($result), sprintf($msg, 'Returned the wrong result')); }
/** * Create a new View object * * @param string $viewName The name of the view we're getting a View object for. * @param string $viewType The type of the View object. By default it's "html". * @param array $config Optional MVC configuration values for the View object. * * @return View */ public function view($viewName, $viewType = 'html', array $config = array()) { try { return parent::view($viewName, $viewType, $config); } catch (ViewNotFound $e) { $magic = new Magic\ViewFactory($this->container); // Let's pass the section override (if any) $magic->setSection($this->getSection()); return $magic->make($viewName, $viewType, $config); } }