Exemplo n.º 1
0
 /**
  * Initializes repository (reads file, or remote address).
  */
 protected function initialize()
 {
     parent::initialize();
     if (!$this->file->exists()) {
         return;
     }
     try {
         $packages = $this->file->read();
         if (!is_array($packages)) {
             throw new \UnexpectedValueException('Could not parse package list from the repository');
         }
     } catch (\Exception $e) {
         throw new InvalidRepositoryException('Invalid repository data in ' . $this->file->getPath() . ', packages could not be loaded: [' . get_class($e) . '] ' . $e->getMessage());
     }
     $loader = new ArrayLoader(null, true);
     foreach ($packages as $packageData) {
         $package = $loader->load($packageData);
         $this->addPackage($package);
     }
 }
Exemplo n.º 2
0
 /**
  * Load a repository containing available upgrades.
  *
  * @return null|RepositoryInterface
  */
 private function getUpgradeRepository()
 {
     $upgradeFile = $this->getTensideDataDir() . DIRECTORY_SEPARATOR . 'upgrades.json';
     if (!file_exists($upgradeFile)) {
         return null;
     }
     $packageLoader = new ArrayLoader();
     $packageChanges = new WritableArrayRepository();
     $upgrades = new JsonFile($upgradeFile, null);
     foreach ($upgrades->getEntries('/') as $packageName) {
         if ($pkgData = $upgrades->get($packageName . '/target')) {
             $packageChanges->addPackage($packageLoader->load($pkgData));
         }
     }
     return $packageChanges;
 }