updateVersion($this->getExtension(), $version); } /** * Test if $version is the current version * * @param string $version * @return boolean */ public function isVersion($version) { $extensionsManager = $this->getServiceManager()->get(common_ext_ExtensionsManager::SERVICE_ID); return $version == $extensionsManager->getInstalledVersion($this->getExtension()->getId()); } /** * Please use "skip" instead of inBetween. * * @param string $minVersion * @param string $maxVersion * @return boolean */ public function isBetween($minVersion, $maxVersion) { $current = common_ext_ExtensionsManager::singleton()->getInstalledVersion($this->getExtension()->getId()); return version_compare($minVersion, $current, '<=') && version_compare($current, $maxVersion, '<='); } /** * Skip from version FROM to version TO without additional required actions * * @param string $from * @param string $to */ public function skip($from, $to) { $current = common_ext_ExtensionsManager::singleton()->getInstalledVersion($this->getExtension()->getId()); if (version_compare($from, $current, '<=') && version_compare($current, $to, '<')) { $this->setVersion($to); } } /** * @return Report[] */ public function getReports() { return $this->reports; } /** * @param Report $report */ public function addReport(Report $report) { $this->reports[] = $report; } /** * Loads a service in a "safe" way, trying to convert * unknown classes to abstract services * * @param string $configId * @return */ public function safeLoadService($configId) { /** * Inline autoloader that will construct a new class based on ConfigurableService * @param string $class_name */ $missingClasses = []; $fallbackAutoload = function ($class_name) use (&$missingClasses) { $missingClasses[] = $class_name; $split = strrpos($class_name, '\\'); if ($split == false) { $result = eval('class ' . $class_name . ' extends oat\\oatbox\\service\\ConfigurableService {}'); } else { $namespace = substr($class_name, 0, $split); $class = substr($class_name, $split + 1); eval('namespace ' . $namespace . '; ' . 'class ' . $class . ' extends \\oat\\oatbox\\service\\ConfigurableService {}'); } }; $serviceManager = $this->getServiceManager(); spl_autoload_register($fallbackAutoload); $service = $serviceManager->get($configId); spl_autoload_unregister($fallbackAutoload); return $service; } }