Example #1
0
 /**
  * @param string $epId
  * @param bool $installedByDefault
  * @return Item
  */
 public function getResolverItem($epId)
 {
     $action = $this->getInstallAction($epId);
     if ($action == Resolver::ACTION_UPGRADE) {
         $item = new Item($this->moduleInfos->name, true, $this->moduleInfos->version, Resolver::ACTION_UPGRADE, $this->moduleStatuses[$epId]->version);
     } else {
         $item = new Item($this->moduleInfos->name, $this->isInstalled($epId), $this->moduleInfos->version, $action);
     }
     foreach ($this->moduleInfos->dependencies as $dep) {
         $item->addDependency($dep['name'], $dep['version']);
     }
     $item->setProperty('component', $this);
     return $item;
 }
Example #2
0
 /**
  * check reverse dependencies of an item to remove.
  *
  * Find all items having the given item as dependency, and remove them
  *
  * @param Item   $item
  * @param string $epId
  */
 protected function _checkReverseDependencies(Item $item)
 {
     if (isset($this->circularReverseDependencyTracker[$item->getName()])) {
         throw new ItemException('Circular reverse dependency! Cannot process the item ' . $item->getName(), $item, 4);
     }
     $this->circularReverseDependencyTracker[$item->getName()] = true;
     foreach ($this->items as $revdepItemName => $revdepItem) {
         $dependencies = $revdepItem->getDependencies();
         if (!isset($dependencies[$item->getName()])) {
             continue;
         }
         if ($revdepItem->getAction() == self::ACTION_INSTALL || $revdepItem->getAction() == self::ACTION_UPGRADE) {
             throw new ItemException('Item ' . $revdepItemName . ' should be removed because of the removal of one of its dependencies, ' . $item->getName() . ', but it asked to be install/upgrade at the same time', $item, 5, $revdepItem);
         }
         if (isset($this->checkedItems[$revdepItemName])) {
             continue;
         }
         if ($revdepItem->getAction() == self::ACTION_REMOVE) {
             $this->_checkReverseDependencies($revdepItem);
             $this->chain[] = $revdepItem;
         } elseif ($revdepItem->getAction() == self::ACTION_NONE) {
             if ($revdepItem->isInstalled()) {
                 $revdepItem->setAction(self::ACTION_REMOVE);
                 $this->_checkReverseDependencies($revdepItem);
                 $this->chain[] = $revdepItem;
             }
         }
     }
     $this->checkedItems[$item->getName()] = true;
     unset($this->circularReverseDependencyTracker[$item->getName()]);
 }