コード例 #1
0
 /**
  * Löscht eine Entität aus einem Modul
  */
 public function deleteEntity()
 {
     $this->current = Modules::getModule($this->request->current);
     $this->current->model->removeEntity($this->request->id);
     $this->current->save();
     $this->request->clear();
     $this->request->id = $this->current->qualifiedName;
     // TODO: Dateien von der Platte löschen
     // TODO: Tabelle aus Datenbank löschen
 }
コード例 #2
0
 /**
  * @param Module $module
  * @param string $entity
  */
 public function createCrudCode(Module $module, $entity)
 {
     // Index-Aktion
     $action = new Action();
     $action->name = "index{$entity}";
     $action->description = "{$entity}-Übersicht";
     $action->addToMenu = 1;
     $action->next = Action::NEXT_VIEW;
     $action->securityLevel = Action::LEVEL_CONFIG;
     $action->nextItem = "index{$entity}";
     $module->actions[] = $action;
     // Show-Aktion
     $action = new Action();
     $action->name = "show{$entity}";
     $action->description = "{$entity} anzeigen";
     $action->addToMenu = 1;
     $action->next = Action::NEXT_VIEW;
     $action->securityLevel = Action::LEVEL_CONFIG;
     $action->nextItem = "show{$entity}";
     $module->actions[] = $action;
     // Init-Aktion
     $action = new Action();
     $action->name = "init{$entity}";
     $action->description = "{$entity} anlegen";
     $action->addToMenu = 0;
     $action->next = Action::NEXT_VIEW;
     $action->securityLevel = "edit{$entity}";
     $action->nextItem = "edit{$entity}";
     $module->actions[] = $action;
     // Edit-Aktion
     $action = new Action();
     $action->name = "edit{$entity}";
     $action->description = "{$entity} bearbeiten";
     $action->addToMenu = 0;
     $action->next = Action::NEXT_VIEW;
     $action->securityLevel = Action::LEVEL_CONFIG;
     $action->nextItem = "edit{$entity}";
     $module->actions[] = $action;
     // Update-Aktion
     $action = new Action();
     $action->name = "update{$entity}";
     $action->description = "{$entity} speichern";
     $action->addToMenu = 0;
     $action->next = Action::NEXT_ACTION;
     $action->securityLevel = "edit{$entity}";
     $action->nextItem = "index{$entity}";
     $module->actions[] = $action;
     // Create-Aktion
     $action = new Action();
     $action->name = "create{$entity}";
     $action->description = "{$entity} speichern (neuer Datensatz)";
     $action->addToMenu = 0;
     $action->next = Action::NEXT_ACTION;
     $action->securityLevel = "edit{$entity}";
     $action->nextItem = "index{$entity}";
     $module->actions[] = $action;
     // DeleteAktion
     $action = new Action();
     $action->name = "delete{$entity}";
     $action->description = "{$entity} löschen";
     $action->addToMenu = 0;
     $action->next = Action::NEXT_ACTION;
     $action->securityLevel = "edit{$entity}";
     $action->nextItem = "index{$entity}";
     $module->actions[] = $action;
     $module->save();
     // Views erzeugen
     $search = array('PRIMARY', 'CLASSNAME', 'CLASS', 'MODULENAME', 'MODULE', 'NAMESPACE');
     $replace = array('PRIMARY', $entity, strtolower($entity), ucfirst($module->name), $module->name, $module->namespace);
     $path = $module->getPath() . '/Views/';
     $this->variablenEinsetzen(__DIR__ . '/Prototype/Index.template', $path . 'Index' . $entity . '.php', $search, $replace);
     $this->variablenEinsetzen(__DIR__ . '/Prototype/Show.template', $path . 'Show' . $entity . '.php', $search, $replace);
     $this->variablenEinsetzen(__DIR__ . '/Prototype/Edit.template', $path . 'Edit' . $entity . '.php', $search, $replace);
     // CONTROLLER erweitern
     /*
     // TODO: Pfade
     $path = 'NewFrontiers/Modules/' . ucfirst($this->current->name) . '/';
     $controller = file_get_contents($path . ucfirst($this->current->name) . 'Controller.php');
     $template = file_get_contents(__DIR__ . '/Prototype/CRUD.template');
     $template = str_replace('CLASSNAME_LOWER', strtolower($entity), $template);
     $template = str_replace('CLASSNAME', $entity, $template);
     
     // Falls das Ende Kommentar gefunden wird dort anhängen, ansonsten halt ganz nach unten
     if (strpos($controller, '// CONTROLLER-ENDE') !== false) {
         $controller = str_replace('// CONTROLLER-ENDE', $template . "\n\n // CONTROLLER-ENDE", $controller);
     } else {
         $controller .= $template;
     }
     file_put_contents($path . $this->current->name . 'Controller.php', $controller);
     */
 }