PHP Класс Puli\Repository\JsonRepository

The generated JSON file is described by res/schema/repository-schema-1.0.json. Resources can be added with the method {@link add()}: php use Puli\Repository\JsonRepository; $repo = new JsonRepository('/path/to/repository.json', '/path/to/project'); $repo->add('/css', new DirectoryResource('/path/to/project/res/css')); When adding a resource, the added filesystem path is stored in the JSON file under the key of the Puli path. The path is stored relatively to the base directory passed to the constructor: json { "/css": "res/css" } Mapped resources can be read with the method {@link get()}: php $cssPath = $repo->get('/css')->getFilesystemPath(); You can also access nested files: php echo $repo->get('/css/style.css')->getBody(); Nested files are searched during {@link get()}. As a consequence, this implementation should not be used in production environments. Use {@link OptimizedJsonRepository} instead which searches nested files during {@link add()} and has much faster read performance.
С версии: 1.0
Автор: Bernhard Schussek ([email protected])
Автор: Titouan Galopin ([email protected])
Наследование: extends AbstractJsonRepository, implements Puli\Repository\Api\EditableRepository
Показать файл Открыть проект

Открытые методы

Метод Описание
__construct ( string $path, string $baseDirectory, boolean $validateJson = false ) Creates a new repository.
getVersions ( $path )

Защищенные методы

Метод Описание
getReferencesForGlob ( $glob, $flags )
getReferencesForPath ( $path )
getReferencesForRegex ( $staticPrefix, $regex, $flags, $maxDepth )
getReferencesInDirectory ( $path, $flags )
insertReference ( $path, $reference )
removeReferences ( $glob )
storeVersion ( Puli\Repository\Api\Resource\PuliResource $resource )

Приватные методы

Метод Описание
appendPathAndFilterExisting ( array $references, string $nestedPath, integer $flags ) : string[] Appends nested paths to references and filters out the existing ones.
flatten ( array $references ) : string[] | null[] Flattens a two-level reference array into a one-level array.
flattenWithFilter ( array $references, string $regex, integer $flags, integer $maxDepth ) : string[] | null[] Flattens a two-level reference array into a one-level array and filters out any references that don't match the given regular expression.
followLinks ( array $references, integer $flags ) : string[] | null[] Follows any link in a list of references.
getPathDepth ( string $path ) : integer Returns the depth of a Puli path.
initWithDefaultOrder ( string $path, string $insertedPath, array $references ) Initializes the order of a path with the default order.
initWithParentOrder ( string $path, array $parentReferences ) Initializes a path with the order of the closest parent path.
prependOrderEntry ( string $path, string $prependedPath ) Inserts a path at the beginning of the order list of a mapped path.
resolveReferences ( string $path, mixed $references, integer $flags ) : string[] | null[] Resolves a list of references stored in the JSON.
searchReferences ( string $searchPath, integer $flags ) : array Filters the JSON file for all references relevant to a given search path.

Описание методов

__construct() публичный Метод

Creates a new repository.
public __construct ( string $path, string $baseDirectory, boolean $validateJson = false )
$path string The path to the JSON file. If relative, it must be relative to the base directory.
$baseDirectory string The base directory of the store. Paths inside that directory are stored as relative paths. Paths outside that directory are stored as absolute paths.
$validateJson boolean Whether to validate the JSON file against the schema. Slow but spots problems.

getReferencesForGlob() защищенный Метод

protected getReferencesForGlob ( $glob, $flags )

getReferencesForPath() защищенный Метод

protected getReferencesForPath ( $path )

getReferencesForRegex() защищенный Метод

protected getReferencesForRegex ( $staticPrefix, $regex, $flags, $maxDepth )

getReferencesInDirectory() защищенный Метод

protected getReferencesInDirectory ( $path, $flags )

getVersions() публичный Метод

public getVersions ( $path )

insertReference() защищенный Метод

protected insertReference ( $path, $reference )

removeReferences() защищенный Метод

protected removeReferences ( $glob )

storeVersion() защищенный Метод

protected storeVersion ( Puli\Repository\Api\Resource\PuliResource $resource )
$resource Puli\Repository\Api\Resource\PuliResource