Exemple #1
0
 /**
  * Конструктор формирует массив доступных версий для пакету $name
  * В конструктор передан объект Package, который будет еслинственным
  * елементом массива filtered
  * 
  * @param string $name имя пакета
  */
 function __construct($packageName)
 {
     if ($packageName instanceof Package) {
         $this->name = $packageName->name;
         $this->filtered = array($packageName);
     } else {
         $this->name = $packageName;
         $this->filtered = PackageManager::getRepositoryList()->getAvaibleVersions($packageName);
     }
     //print_pre(count($this->filtered));
     //foreach($this->filtered as $p) io::out($p->name.' '.$p->version);
     $iPackage = PackageManager::getInstalledPackage($packageName);
     if ($iPackage instanceof Package) {
         // Оставляем версии больше установленной
         $this->merge($iPackage->version, 'gt');
         // добавляем в начало массива установленную версию.
         // Она будет самой младшей версией из доступных.
         array_unshift($this->filtered, $iPackage);
     }
     //foreach($this->filtered as $p) io::out($p->name.' '.$p->version);
 }
Exemple #2
0
 /**
  *
  * @throws RepositoryException 
  */
 function delivery($targetFile)
 {
     if ($this->file instanceof iFile && $this->file->getAbsPath() != $targetFile->getAbsPath()) {
         $this->file->copy($targetFile);
     } else {
         try {
             PackageManager::getRepositoryList()->fetchPackage($this->urls, $targetFile);
         } catch (RepositoryListException $e) {
             io::out('Error while fetching file');
         }
     }
     if (($p = Package::isPackage($targetFile)) === false) {
         throw new PackageException('Fetched file(' . $targetFile . ') isn\'t a package');
     }
     return $p;
 }