Create a new Controller object
public controller ( string $viewName, array $config = [] ) : |
||
$viewName | string | The name of the view we're getting a Controller for. |
$config | array | Optional MVC configuration values for the Controller object. |
return |
/** * @group SwitchFactory * @covers FOF30\Factory\SwitchFactory::controller * @dataProvider SwitchFactoryDataprovider::getTestController */ public function testController($test, $check) { $msg = 'SwitchFactory::controller %s - Case: ' . $check['case']; $platform = static::$container->platform; $platform::$isAdmin = $test['backend']; $factory = new SwitchFactory(static::$container); $result = $factory->controller($test['view']); $this->assertEquals($check['result'], get_class($result), sprintf($msg, 'Returned the wrong result')); }
/** * Create a new Controller object * * @param string $viewName The name of the view we're getting a Controller for. * @param array $config Optional MVC configuration values for the Controller object. * * @return Controller */ public function controller($viewName, array $config = array()) { try { return parent::controller($viewName, $config); } catch (ControllerNotFound $e) { $magic = new Magic\ControllerFactory($this->container); return $magic->make($viewName, $config); } }
/** * Create a new Controller object * * @param string $viewName The name of the view we're getting a Controller for. * @param array $config Optional MVC configuration values for the Controller object. * * @return Controller */ public function controller($viewName, array $config = array()) { try { return parent::controller($viewName, $config); } catch (ControllerNotFound $e) { $magic = new Magic\ControllerFactory($this->container); // Let's pass the section override (if any) $magic->setSection($this->getSection()); return $magic->make($viewName, $config); } }