Ejemplo n.º 1
0
 /**
  * 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;
 }
Ejemplo n.º 2
0
 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();
 }
Ejemplo n.º 3
0
 /**
  * @covers ViewFactory::getView
  */
 public function testDefaultMapperCanBeConstructed()
 {
     $viewFactory = new ViewFactory();
     $this->assertInstanceOf('StdClass', $viewFactory->getView('StdClass', new Request(), new Response()));
 }