/** * Returns the view to display. * * @return string * @todo select view instance based on controller name */ public function getView($controllerName, $result) { // On redirect, load default view object and tell it to redirect. if (isset($this->redirects[$controllerName][$result])) { $view = $this->viewFactory->getView(); $view->setRedirect($this->redirects[$controllerName][$result]); return $view; } // If no view script is configured, we don't know what to do. if (!isset($this->views[$controllerName][$result])) { throw new Exception('Controller "' . $controllerName . '" result "' . $result . '" has no view script'); } // Get the "real" view object (depending on the view script). $view = $this->viewFactory->getView($this->views[$controllerName][$result]); return $view; }
public function indexAction() { /* Once upon a time $shapes was extracted from $_REQUEST and successfully validated. * And now $shapes is array like this: * $shapes = [ * ['type' => 'circle', 'params' => [...]], * ['type' => 'circle', 'params' => [...]] * ]; * * We believe in it. */ $shapes = Request::getShapes(); $shapes = new ShapesCollection($shapes); $view = ViewFactory::getView(Request::getViewType()); while ($shape = $shapes->getShape()) { $view->assignShape($shape); } $view->render(); }
/** * @covers ViewFactory::getView */ public function testDefaultMapperCanBeConstructed() { $viewFactory = new ViewFactory(); $this->assertInstanceOf('StdClass', $viewFactory->getView('StdClass', new Request(), new Response())); }