/**
  * Lädt das Modul mit dem übergebenen Namen
  * @param $name
  * @return Module|null
  */
 public function getModule($name)
 {
     if ($name === '') {
         Logging::warning('Leeres Modul sollte geladen werden.');
         return null;
     }
     $name = ucfirst($name);
     // Aus dem Cache holen
     $cacheId = 'module.' . $name;
     if (array_key_exists($cacheId, $this->internalCache)) {
         return $this->internalCache[$cacheId];
     }
     $result = Cache::get($cacheId, null);
     if ($result !== null) {
         $this->internalCache[$cacheId] = $result;
         return $result;
     }
     Profiler::startSection('module.load', $name);
     Logging::debug("Modul '{$name}' wird geladen");
     // Generieren der Klassendefinition für den Controller um dann via
     // Reflection die Datei und damit das Verzeichnis herauszubekommen.
     $naming = new ModuleNaming();
     $classOfController = $naming->getControllerClassFromCamelCase($name);
     if (class_exists($classOfController)) {
         $reflector = new ReflectionClass($classOfController);
         $directory = dirname($reflector->getFileName());
         $filename = $directory . '/Module.xml';
         if (file_exists($filename)) {
             $file = simplexml_load_file($filename);
             $result = $this->createByXml($file, $directory);
             unset($file);
         } else {
             Logging::error("Modul [{$name}] konnte in Pfad {$directory} nicht gefunden werden");
         }
     } else {
         Logging::warning("Controller für Modul [{$name}] konnte nicht gefunden werden [{$classOfController}]");
     }
     Cache::set($cacheId, $result);
     $this->internalCache[$cacheId] = $result;
     Profiler::endSection('module.load');
     return $result;
 }
 public function createModule($fullyQualifiedName, Request $request)
 {
     Logging::info("Modul {$fullyQualifiedName} wird angelegt");
     $naming = new ModuleNaming();
     $module = new Module();
     $module->namespace = $fullyQualifiedName;
     $module->qualifiedName = $naming->getQualifiedNameFromNamespace($module->namespace);
     $module->name = $naming->getSimpleNameFromNamespace($module->namespace);
     $module->path = str_replace('\\', '/', $fullyQualifiedName);
     $path = $module->getPath();
     $controller = $path . '/' . ucwords($module->name) . 'Controller.php';
     $installer = $path . '/' . ucwords($module->name) . 'Installer.php';
     // Verzeichnisse anlegen
     mkdir($path, 0777, true);
     mkdir($path . '/Views');
     mkdir($path . '/Model');
     $search = array('%MODULE%', '%AUTHOR%', '%VERSION%', '%DESCRIPTION%', '%NAMESPACE%');
     $replace = array(ucwords($module->name), $request->author, $request->version, $request->description, $module->namespace);
     // Variablen ersetzen und Dateien speichern
     $this->variablenEinsetzen(__DIR__ . '/Prototype/Controller.template', $controller, $search, $replace);
     $this->variablenEinsetzen(__DIR__ . '/Prototype/Module.xml', $path . '/Module.xml', $search, $replace);
     $this->variablenEinsetzen(__DIR__ . '/Prototype/Installer.template', $installer, $search, $replace);
     return $module;
 }