/** * @var ModuleInfo module info for module */ public static function forModule($module) { if (self::$moduleInfoStub == null) { $stubFile = new File(dirname(__FILE__) . '/' . self::MODULE_INFO_STUB_FILENAME); self::$moduleInfoStub = $stubFile->includeFile(); } if (!array_key_exists($module, self::$moduleInfos)) { self::$moduleInfos[$module] = new ModuleInfo($module); } return self::$moduleInfos[$module]; }
/** * * @param string $deploymentDescriptorPath absolute path of descriptor file * $return array module deployment descriptor */ public function deploy() { $compontens = []; $models = []; $modules = []; $moduleInfo = []; $moduleInfoFile = new File("{$this->modulePath}/" . ModuleInfo::MODULE_INFO_FILENAME); if ($moduleInfoFile->exists()) { $moduleInfo = $moduleInfoFile->includeFile(); } else { $this->log->console("Missing module info file in {$this->modulePath}", null, Log::WARNING); } $componentsDir = new Directory("{$this->modulePath}/" . self::COMPONENTS_FOLDER); if ($componentsDir->exists()) { $compontens = $componentsDir->getFiles(true, self::PHP_FILE_FILTER); } $modelsDir = new Directory("{$this->modulePath}/" . self::MODELS_FOLDER); if ($modelsDir->exists()) { $modelsTmp = $modelsDir->getFiles(true, self::PHP_FILE_FILTER); foreach ($modelsTmp as $modelPath) { $class = substr($modelPath, strrpos($this->modulePath, DS) + 1); // remove path $class = substr($class, 0, -4); // remove .php extendsion $class = str_replace(DS, '\\', $class); // direectory separator to namespace separator $models[$class] = $modelPath; } } $modulesDir = new Directory("{$this->modulePath}/" . self::MODULES_FOLDER); if ($modulesDir->exists()) { foreach ($modulesDir->getDirectories() as $subModulePath) { $moduleName = substr(str_replace($modulesDir->getPath(), '', $subModulePath), 1); $subModuleDeployer = new ModuleDeployer($subModulePath); $modules[$moduleName] = $subModuleDeployer->deploy(); } } return ['path' => $this->modulePath, 'compontents' => $compontens, 'modules' => $modules, 'models' => $models, 'info' => $moduleInfo]; }
private function scanApplications($app, $appPath) { $info = []; $moduleInfoFile = new File("{$appPath}/" . ModuleInfo::MODULE_INFO_FILENAME); if ($moduleInfoFile->exists()) { $info = $moduleInfoFile->includeFile(); } else { $this->log->console("Missing module info file in {$appPath}", null, Log::WARNING); } $this->addModule($app, ['path' => $appPath, 'info' => $info]); }