/**
  * Rahmen zum Ausführen einer Funktion. Konkrete Ausführeung wird
  * von abstrakter Methode executeAction ausgeführt
  * @param $request
  * @return Response
  * @throws Exception
  */
 public function execute($request)
 {
     // Der Response wird direkt am Anfang erzeugt und auch in der Application-Klasse
     // hinterlegt. Das muss aus Gründen der Abwärtskompatibilität sein. In den Controller
     // Methiden wird oft auf Application::currentResponse zurückgegriffen. Das muss an
     // dieser Stelle also gefüllt sein.
     Logging::info("Ausführen von [{$this->request->module}:{$this->request->action}]");
     Profiler::startSection($this->request->module . '.' . $this->request->action);
     $this->request = $request;
     $this->response = new Response();
     Application::getInstance()->setResponse($this->response);
     $this->currentAction = $this->module->getAction($this->request->action);
     // Abbrechen, wenn Aktion nicht gefunden werden konnte
     if ($this->currentAction === null) {
         throw new \DomainException("Aktion '{$this->request->action}' in Modul '{$this->request->module}' nicht gefunden");
     } else {
         // Verhindern, dass von einem Angreifer eine beliebige Seite aufgerufen werden
         // kann
         $this->request->view = null;
         // Response mit den Standard-Daten füllen
         $this->response->setContent($this->currentAction->getDefaultNext($this));
         $result = $this->innerExecute();
         if ($result !== null) {
             $this->response = $result;
         }
         // Jetzt kann sich unter Umständen der View geändert haben
         if ($this->request->view !== null) {
             Logging::warning('anderen View laden');
             $this->response->setContent($this->module->loadView($this->request->view, $this));
         }
         // Überschreiben der eigentlichen Aktion durch eine, die bei der Ausführung der Funktion
         // gesetzt wurde
         if ($this->request->action !== $this->currentAction->name) {
             Logging::warning('Andere Action ausführen');
             $this->response->setContent($this->module->getAction($this->request->action));
         }
         Profiler::endSection($this->request->module . '.' . $this->request->action);
         return $this->response;
     }
 }
 /**
  * Legt die Source-Datei für die neue Entität an
  *
  * @param Module $module
  * @param $entity
  * @param Request $request
  */
 public function createEntity(Module $module, $entity, Request $request)
 {
     $path = $module->getPath();
     $search = array('%MODULE%', '%CLASSNAME%', '%TABLENAME%', '%NAMESPACE%', '%QUALIFIEDMODULE%');
     $replace = array(ucfirst($module->name), $request->klasse, $entity->name, $module->namespace, $module->qualifiedName);
     $this->variablenEinsetzen(__DIR__ . '/Prototype/Entity.template', $path . '/Model/' . $request->klasse . '.php', $search, $replace);
 }
 /**
  * Diese Methode legt ein neues Entity an und legt das erzeugte Entity
  * in der Entity-Property dieser Klasse ab.
  * @param Module $module
  * @param $entityName
  * @param Request $request
  * @throws InvalidArgumentException
  */
 protected function entitaetAnlegen(Module $module, $entityName, Request $request)
 {
     if ($module === null) {
         throw new InvalidArgumentException('Kein Modul übergeben');
     }
     $this->entity = new EntityDefinition();
     $this->entity->name = $entityName;
     $this->entity->match = $entityName;
     $module->addEntity($this->entity);
     $create = new CodeCreation();
     $create->createEntity($module, $this->entity, $request);
 }