Exemplo n.º 1
0
 /**
  * Start an addon and make it available.
  *
  * @param Addon $addon The addon to start.
  */
 public function startAddon(Addon $addon)
 {
     $this->enabled[$addon->getType() . '/' . $addon->getKey()] = $addon;
     $this->enabledSorted = count($this->enabled) <= 1;
     if ($addon->getType() === Addon::TYPE_THEME) {
         if (isset($this->theme)) {
             $this->stopAddon($this->theme);
         }
         $this->theme = $addon;
         $this->themeSubdirs = null;
     }
     // Add the addon's classes to the autoload list.
     foreach ($addon->getClasses() as $classKey => $row) {
         list($_, $subpath) = $row;
         if (isset($this->autoloadClasses[$classKey])) {
             // There is already a class registered here. Only override if higher priority.
             if ($this->autoloadClasses[$classKey][1]->getPriority() < $addon->getPriority()) {
                 $bak = $this->autoloadClasses[$classKey];
                 $this->autoloadClasses[$classKey] = [$addon->path($subpath), $addon];
             } else {
                 $bak = [$addon->path($subpath), $addon];
             }
             $this->autoloadClassesBak[$classKey][] = $bak;
         } else {
             $this->autoloadClasses[$classKey] = [$addon->path($subpath), $addon];
         }
     }
 }