/**
  * Loads the configuration file and returns it.
  *
  * @param string $file The configuration file path.
  *
  * @return Configuration The configuration settings.
  */
 public function loadFile($file = null)
 {
     if (null === $file) {
         $file = $this->getDefaultPath();
     }
     $json = $this->json->decodeFile($file);
     $this->json->validate($this->json->decodeFile(BOX_SCHEMA_FILE), $json);
     return new Configuration($file, $json);
 }
Esempio n. 2
0
 /**
  * Loads the configuration file and returns it.
  *
  * @param string $file The configuration file path.
  *
  * @return Configuration The configuration settings.
  */
 public function loadFile($file = null)
 {
     if (null === $file) {
         $file = $this->getDefaultPath();
     }
     $json = $this->json->decodeFile($file);
     if (isset($json->import)) {
         if (!Path::isAbsolute($json->import)) {
             $json->import = Path::join(array(dirname($file), $json->import));
         }
         $json = (object) array_merge((array) $this->json->decodeFile($json->import), (array) $json);
     }
     $this->json->validate($this->json->decodeFile(CRATE_SCHEMA_FILE), $json);
     return new Configuration($file, $json);
 }
Esempio n. 3
0
 /**
  * Validates the data, processes it, and returns a new instance of Manifest.
  *
  * @param array $decoded The decoded JSON data.
  * @param Json  $json    The Json instance used to decode the data.
  *
  * @return Manifest The new instance.
  */
 private static function create($decoded, Json $json)
 {
     $json->validate($json->decodeFile(PHAR_UPDATE_MANIFEST_SCHEMA), $decoded);
     $updates = array();
     foreach ($decoded as $update) {
         $updates[] = new Update($update->name, $update->sha1, $update->url, Version::create($update->version), isset($update->publicKey) ? $update->publicKey : null);
     }
     usort($updates, function (Update $a, Update $b) {
         return $a->getVersion()->compareTo($b->getVersion());
     });
     return new static($updates);
 }