/** * Stop an addon and make it unavailable. * * @param Addon $addon The addon to stop. */ public function stopAddon(Addon $addon) { if (empty($addon)) { trigger_error("Null addon supplied to AddonManager->stopAddon().", E_USER_NOTICE); return; } unset($this->enabled[$addon->getType() . '/' . $addon->getKey()]); // Remove all of the addon's classes from the autoloader. foreach ($addon->getClasses() as $classKey => $row) { // list($class, $subpath) = $row; unset($this->autoloadClasses[$classKey]); // See if there is another class that can be registered in place. if (!empty($this->autoloadClassesBak[$classKey])) { foreach ($this->autoloadClassesBak[$classKey] as $i => $rowBak) { list($path, $addon) = $rowBak; /* @var Addon $maxAddon */ if (!isset($maxAddon) || $maxAddon->getPriority() < $addon->getPriority()) { $maxAddon = $addon; $maxIndex = $i; } } if (isset($maxIndex)) { $this->autoloadClasses[$classKey] = $this->autoloadClassesBak[$classKey][$maxIndex]; unset($this->autoloadClassesBak[$classKey][$maxIndex]); } } } }