The path of the file can be accessed with {@link getFilesystemPath}.
Since: 1.0
Author: Bernhard Schussek (bschussek@gmail.com)
Inheritance: extends Puli\Repository\Api\Resource\PuliResource
Exemplo n.º 1
0
 /**
  * Transform resource into a config array
  * @param FilesystemResource $resource
  * @return array 
  */
 public function transform(FilesystemResource $resource)
 {
     $config = json_decode($resource->getBody(), true);
     return $this->validateConfig($config) ? $config : [];
 }
Exemplo n.º 2
0
 /**
  * Validate extension
  * @param FilesystemResource $resource
  * @return bool
  */
 public function validateExtension(FilesystemResource $resource)
 {
     return pathinfo($resource->getPath(), PATHINFO_EXTENSION) === $this->getExtension();
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 protected function addFilesystemResource($path, FilesystemResource $resource)
 {
     // Read children before attaching the resource to this repository
     $children = $resource->listChildren();
     parent::addFilesystemResource($path, $resource);
     // Recursively add all child resources
     $basePath = '/' === $path ? $path : $path . '/';
     foreach ($children as $name => $child) {
         $this->addFilesystemResource($basePath . $name, $child);
     }
 }
Exemplo n.º 4
0
 /**
  * Transform resource into a config array
  * @param FilesystemResource $resource
  * @return array 
  */
 public function transform(FilesystemResource $resource)
 {
     $path = $resource->getFilesystemPath();
     $config = (require $path);
     return $this->validateConfig($config) ? $config : [];
 }