/** * Constructor. * * @param array $params */ public function __construct(BOL_Plugin $plugin) { $this->dirName = trim($plugin->getModule()); $this->key = trim($plugin->getKey()); $this->active = (bool) $plugin->isActive; $this->dto = $plugin; }
/** * @param BOL_Plugin $dto * @return OW_Plugin */ public function getPluginObject(BOL_Plugin $dto) { return $dto->isSystem ? new OW_SystemPlugin(array('dir_name' => $dto->getModule(), 'key' => $dto->getKey(), 'active' => $dto->isActive(), 'dto' => $dto)) : new OW_Plugin(array('dir_name' => $dto->getModule(), 'key' => $dto->getKey(), 'active' => $dto->isActive(), 'dto' => $dto)); }
/** * Installs plugins. * Installs all available system plugins */ public function installSystemPlugins() { $files = UTIL_File::findFiles(OW_DIR_SYSTEM_PLUGIN, array("xml"), 1); $pluginData = array(); $tempPluginData = array(); // first element should be BASE plugin foreach ($files as $file) { $tempArr = $this->readPluginXmlInfo($file); $pathArr = explode(DS, dirname($file)); $tempArr["dir_name"] = array_pop($pathArr); if ($tempArr["key"] == "base") { $pluginData[$tempArr["key"]] = $tempArr; } else { $tempPluginData[$tempArr["key"]] = $tempArr; } } foreach ($tempPluginData as $key => $val) { $pluginData[$key] = $val; } if (!array_key_exists("base", $pluginData)) { throw new LogicException("Base plugin is not found in `{$basePluginRootDir}`!"); } // install plugins list foreach ($pluginData as $pluginInfo) { $pluginDto = new BOL_Plugin(); $pluginDto->setTitle(!empty($pluginInfo["title"]) ? trim($pluginInfo["title"]) : "No Title"); $pluginDto->setDescription(!empty($pluginInfo["description"]) ? trim($pluginInfo["description"]) : "No Description"); $pluginDto->setKey(trim($pluginInfo["key"])); $pluginDto->setModule($pluginInfo["dir_name"]); $pluginDto->setIsActive(true); $pluginDto->setIsSystem(true); $pluginDto->setBuild((int) $pluginInfo["build"]); if (!empty($pluginInfo["developerKey"])) { $pluginDto->setDeveloperKey(trim($pluginInfo["developerKey"])); } $this->pluginListCache[$pluginDto->getKey()] = $pluginDto; $plugin = new OW_Plugin($pluginDto); $this->includeScript($plugin->getRootDir() . BOL_PluginService::SCRIPT_INSTALL); $this->pluginDao->save($pluginDto); $this->updatePluginListCache(); $this->addPluginDirs($pluginDto); } }