protected function genArrayOfComponentFiles($componentName) { $files = array(); $logicComponentNamespace = rtrim($this->config->getParsed('logic_comp_ns'), "\\"); $className = SFComponent::getClassName($componentName); $componentDir = $this->config->getParsed('logic_components_dir'); $files[$componentDir . $componentName . '/' . $componentName . '.php'] = "namespace {$logicComponentNamespace};\n\nuse Framework\\Core\\FrameworkClasses\\Components\\LogicComponent;\n\nclass {$className} extends LogicComponent\n{\n public function init()\n {\n }\n}\n"; $files[$componentDir . $componentName . '/config/' . $componentName . '_config.php'] = ""; return $files; }
protected function genArrayOfComponentFiles($componentName) { $outputComponentDirectory = $this->componentDirectory; $outputComponentTemplateDirectory = $this->outputComponentTemplateDirectory; $languages = $this->config->get('available_langs'); $className = SFComponent::getClassName($componentName); $files = array(); $files[$outputComponentDirectory . "{$componentName}/{$componentName}.php"] = "namespace Components\\Output;\n\nuse Framework\\Core\\FrameworkClasses\\Components\\OutputComponent;\n\nclass {$className} extends OutputComponent\n{\n protected function execute()\n {\n }\n}"; $files[$outputComponentDirectory . "{$componentName}/config/{$componentName}_config.php"] = ""; foreach ($languages as $language) { $files[$outputComponentDirectory . "{$componentName}/lang/{$language}/{$language}.php"] = ""; } $files[$outputComponentTemplateDirectory . "{$componentName}/{$componentName}.tpl"] = "This is component \"{$componentName}\". Hello!"; $files[$outputComponentTemplateDirectory . "{$componentName}/css/{$componentName}.css"] = ""; $files[$outputComponentTemplateDirectory . "{$componentName}/js/{$componentName}.js"] = ""; return $files; }
/** * Loads logic component, by passed component name. * * @param string $logicToLoad Logic component name to load. * @param LogicComponent[] $logicComponentDependencies Logic components that current logic component depends on. * @return LogicComponent Loaded logic component object. * @throws Exception If loaded component does not extends the LogicComponent class. */ public function loadLogicComponent($logicToLoad, array $logicComponentDependencies) { $logicCompDir = $this->logicCompDir . $logicToLoad . '/'; $logicCompConfigDir = $logicCompDir . 'config/'; $this->logger->logDebug("Loading Logic component \"{$logicToLoad}\""); /** @noinspection PhpIncludeInspection */ require_once $logicCompDir . $logicToLoad . '.php'; $configObj = $this->loadComponentConfig($logicCompConfigDir, $logicToLoad); $className = $this->logicComponentNamespace . SFComponent::getClassName($logicToLoad); $logicComponentObj = new $className($logicToLoad, $configObj, $this->dbFactory, $logicComponentDependencies, $this->sf); if (!$logicComponentObj instanceof LogicComponent) { throw new Exception("Component \"{$logicToLoad}\" is not an instance of LogicComponent."); } $logicComponentObj->init(); $this->loadedLogicComponents[$logicToLoad] = $logicComponentObj; return $logicComponentObj; }