Exemplo n.º 1
0
 /**
  * View constructor.
  * @param $controller
  * @param null $includeFile
  */
 public function __construct($controller, $includeFile = null)
 {
     assert($controller !== null, 'Kein Controller übergeben');
     $this->controller = $controller;
     $this->request = $this->controller->getRequest();
     $this->controls = new ControlContainer(null, 'viewContainer');
     $template = $this->getTemplateFile();
     if (isset($template) && strlen($template) > 0) {
         $this->controls->setSkinfile($this->getTemplateFile());
     }
 }
 /**
  * Führt den Request aus
  * @param Controller $controller
  * @param Request $request
  * @return null
  */
 protected function executeRequestViaController(Controller $controller, Request $request)
 {
     $response = null;
     if ($controller->hatBerechtigung()) {
         try {
             $response = $controller->execute($request);
         } catch (Exception $ex) {
             Logging::error($ex->getMessage());
             $response = null;
         }
         if ($response !== null) {
             $content = $response->getContent();
             if ($content instanceof Action) {
                 $request = $request->createSubRequest($request->getArray());
                 $request->module = $content->module->qualifiedName;
                 $request->action = $content->name;
                 $this->handleRequest($request);
             } elseif ($content instanceof View) {
                 if ($request->ajax && $request->dialog) {
                     $this->modalDialog($content);
                     Javascript::display();
                 } elseif ($request->ajax) {
                     $this->flashMessagesAusgeben();
                     $content->display();
                     Javascript::display();
                 } else {
                     $this->display($content);
                 }
             } elseif (is_string($content)) {
                 echo $content;
             } elseif (is_array($content)) {
                 echo json_encode($content);
             }
         }
     } else {
         $this->showNoAccess();
     }
     return $response;
 }