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
示例#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 : [];
 }
 /**
  * Validate extension
  * @param FilesystemResource $resource
  * @return bool
  */
 public function validateExtension(FilesystemResource $resource)
 {
     return pathinfo($resource->getPath(), PATHINFO_EXTENSION) === $this->getExtension();
 }
 /**
  * {@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);
     }
 }
示例#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 : [];
 }