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);
     }
 }