/** * Synchronizes the packages with the file system. */ public static function synchronizeWithFileSystem() { $config = rex::getConfig('package-config'); $addons = self::readPackageFolder(rex_path::src('addons')); $registeredAddons = array_keys(rex_addon::getRegisteredAddons()); foreach (array_diff($registeredAddons, $addons) as $addonName) { $manager = rex_addon_manager::factory(rex_addon::get($addonName)); $manager->_delete(true); unset($config[$addonName]); } foreach ($addons as $addonName) { if (!rex_addon::exists($addonName)) { $config[$addonName]['install'] = false; $config[$addonName]['status'] = false; $registeredPlugins = []; } else { $addon = rex_addon::get($addonName); $config[$addonName]['install'] = $addon->isInstalled(); $config[$addonName]['status'] = $addon->isAvailable(); $registeredPlugins = array_keys($addon->getRegisteredPlugins()); } $plugins = self::readPackageFolder(rex_path::addon($addonName, 'plugins')); foreach (array_diff($registeredPlugins, $plugins) as $pluginName) { $manager = rex_plugin_manager::factory(rex_plugin::get($addonName, $pluginName)); $manager->_delete(true); unset($config[$addonName]['plugins'][$pluginName]); } foreach ($plugins as $pluginName) { $plugin = rex_plugin::get($addonName, $pluginName); $config[$addonName]['plugins'][$pluginName]['install'] = $plugin->isInstalled(); $config[$addonName]['plugins'][$pluginName]['status'] = $plugin->getProperty('status'); } if (isset($config[$addonName]['plugins']) && is_array($config[$addonName]['plugins'])) { ksort($config[$addonName]['plugins']); } } ksort($config); rex::setConfig('package-config', $config); rex_addon::initialize(); }
/** * {@inheritdoc} */ public function checkDependencies() { $check = $addonCheck = parent::checkDependencies(); $dependencies = []; foreach ($this->package->getAvailablePlugins() as $plugin) { $manager = rex_plugin_manager::factory($plugin); if (!$manager->checkDependencies()) { $dependencies[] = $manager->getMessage(); $check = false; } } if (!empty($dependencies)) { if (!$addonCheck) { $this->message .= '<br />'; } $this->message .= implode('<br />', $dependencies); } return $check; }
private function checkRequirements($config) { $temppath = rex_path::addon('.new.' . $this->addonkey); // ---- update "version", "requires" and "conflicts" properties $versions = new SplObjectStorage(); $requirements = new SplObjectStorage(); $conflicts = new SplObjectStorage(); if (isset($config['requires'])) { $requirements[$this->addon] = $this->addon->getProperty('requires'); $this->addon->setProperty('requires', $config['requires']); } if (isset($config['conflicts'])) { $conflicts[$this->addon] = $this->addon->getProperty('conflicts'); $this->addon->setProperty('conflicts', $config['conflicts']); } $versions[$this->addon] = $this->addon->getVersion(); $this->addon->setProperty('version', isset($config['version']) ? $config['version'] : $this->file['version']); $availablePlugins = $this->addon->getAvailablePlugins(); foreach ($availablePlugins as $plugin) { if (is_dir($temppath . '/plugins/' . $plugin->getName())) { $config = rex_file::getConfig($temppath . '/plugins/' . $plugin->getName() . '/' . rex_package::FILE_PACKAGE); if (isset($config['requires'])) { $requirements[$plugin] = $plugin->getProperty('requires'); $plugin->setProperty('requires', $config['requires']); } if (isset($config['conflicts'])) { $conflicts[$plugin] = $plugin->getProperty('conflicts'); $plugin->setProperty('conflicts', $config['conflicts']); } if (isset($config['version'])) { $versions[$plugin] = $plugin->getProperty('version'); $plugin->setProperty('requires', $config['version']); } } } // ---- check requirements $messages = []; $manager = rex_addon_manager::factory($this->addon); if (!$manager->checkRequirements()) { $messages[] = $manager->getMessage(); } if (!$manager->checkConflicts()) { $messages[] = $manager->getMessage(); } if (empty($messages)) { foreach ($availablePlugins as $plugin) { $manager = rex_plugin_manager::factory($plugin); if (!$manager->checkRequirements()) { $messages[] = $plugin->getPackageId() . ': ' . $manager->getMessage(); } if (!$manager->checkConflicts()) { $messages[] = $plugin->getPackageId() . ': ' . $manager->getMessage(); } } foreach (rex_package::getAvailablePackages() as $package) { if ($package->getAddon() === $this->addon) { continue; } $manager = rex_package_manager::factory($package); if (!$manager->checkPackageRequirement($this->addon->getPackageId())) { $messages[] = $package->getPackageId() . ': ' . $manager->getMessage(); } elseif (!$manager->checkPackageConflict($this->addon->getPackageId())) { $messages[] = $package->getPackageId() . ': ' . $manager->getMessage(); } else { foreach ($versions as $reqPlugin) { if (!$manager->checkPackageRequirement($reqPlugin->getPackageId())) { $messages[] = $package->getPackageId() . ': ' . $manager->getMessage(); } if (!$manager->checkPackageConflict($reqPlugin->getPackageId())) { $messages[] = $package->getPackageId() . ': ' . $manager->getMessage(); } } } } } // ---- reset "version", "requires" and "conflicts" properties foreach ($versions as $package) { $package->setProperty('version', $versions[$package]); } foreach ($requirements as $package) { $package->setProperty('requires', $requirements[$package]); } foreach ($conflicts as $package) { $package->setProperty('conflicts', $conflicts[$package]); } return empty($messages) ? true : implode('<br />', $messages); }