/** * Loads a root package file from a file path. * * If the file does not exist, an empty configuration is returned. * * @param string $path The path to the package configuration file. * @param Config $baseConfig The configuration that the package will inherit * its configuration values from. * * @return RootPackageFile The loaded package file. * * @throws StorageException If the file cannot be read. * @throws InvalidConfigException If the file contains invalid * configuration. * @throws UnsupportedVersionException If the version of the package file * is not supported. */ public function loadRootPackageFile($path, Config $baseConfig) { if (!$this->storage->exists($path)) { return new RootPackageFile(null, $path, $baseConfig); } $serialized = $this->storage->read($path); return $this->serializer->unserializeRootPackageFile($serialized, $path, $baseConfig); }
/** * @expectedException \Puli\Manager\Api\Storage\StorageException */ public function testReadFailsIfNotReadable() { // write, no read chmod($this->path, 0200); $this->storage->read($this->path); }
/** * Loads a root package file from a file path. * * If the file does not exist, an empty configuration is returned. * * @param string $path The path to the package configuration file. * @param Config $baseConfig The configuration that the package will inherit * its configuration values from. * * @return RootPackageFile The loaded package file. * * @throws FileNotFoundException If the file does not exist. * @throws ReadException If the file cannot be read. * @throws InvalidConfigException If the file contains invalid * configuration. * @throws UnsupportedVersionException If the version of the package file * is not supported. */ public function loadRootPackageFile($path, Config $baseConfig) { $serialized = $this->storage->read($path); return $this->serializer->unserializeRootPackageFile($serialized, $path, $baseConfig); }