PHP Класс Puli\Repository\AbstractJsonRepository

The generated JSON file is described by res/schema/repository-schema-1.0.json.
С версии: 1.0
Автор: Bernhard Schussek ([email protected])
Автор: Titouan Galopin ([email protected])
Наследование: extends AbstractEditableRepository, implements Psr\Log\LoggerAwareInterface
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$baseDirectory string
$json array

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

Метод Описание
__construct ( string $path, string $baseDirectory, boolean $validateJson = false, Puli\Repository\Api\ChangeStream\ChangeStream $changeStream = null ) Creates a new repository.
add ( $path, $resource )
clear ( )
contains ( $query, $language = 'glob' )
find ( $query, $language = 'glob' )
get ( $path )
hasChildren ( $path )
listChildren ( $path )
remove ( $query, $language = 'glob' )
setLogger ( Psr\Log\LoggerInterface $logger = null )

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

Метод Описание
addFilesystemResource ( string $path, Puli\Repository\Api\Resource\FilesystemResource $resource ) Adds a filesystem resource to the JSON file.
createResource ( string $path, string | null $reference ) : Puli\Repository\Api\Resource\PuliResource Turns a reference into a resource.
flush ( ) Writes the JSON file.
getReferencesForGlob ( string $glob, integer $flags ) : string[] | null[] Returns the references matching a given Puli path glob.
getReferencesForPath ( string $path ) : string[] | null[] Returns the references for a given Puli path.
getReferencesForRegex ( string $staticPrefix, string $regex, integer $flags ) : string[] | null[] Returns the references matching a given Puli path regular expression.
getReferencesInDirectory ( string $path, integer $flags ) : string[] | null[] Returns the references in a given Puli path.
insertReference ( string $path, string | null $reference ) Inserts a path reference into the JSON file.
isFilesystemReference ( string $reference ) : boolean Returns whether a reference contains an absolute or relative filesystem path.
isLinkReference ( string $reference ) : boolean Returns whether a reference contains a link.
load ( ) Loads the JSON file.
log ( mixed $level, string $message ) Logs a message.
logReferenceNotFound ( string $path, string $reference, string $absoluteReference ) Logs a warning that a reference could not be found.
removeReferences ( string $glob ) Removes all path references matching the given glob from the JSON file.

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

Метод Описание
addResource ( string $path, Puli\Repository\Api\Resource\FilesystemResource | LinkResource $resource ) Adds a resource to the repository.
createResources ( array $references ) : array Turns a list of references into a list of resources.
ensureDirectoryExists ( string $path ) Adds all ancestor directories of a path to the repository.
getShortClassName ( string $className ) : string Returns the short name of a fully-qualified class name.

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

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

Creates a new repository.
public __construct ( string $path, string $baseDirectory, boolean $validateJson = false, Puli\Repository\Api\ChangeStream\ChangeStream $changeStream = null )
$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.
$changeStream Puli\Repository\Api\ChangeStream\ChangeStream If provided, the repository will append resource changes to this change stream.

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

public add ( $path, $resource )

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

Adds a filesystem resource to the JSON file.
protected addFilesystemResource ( string $path, Puli\Repository\Api\Resource\FilesystemResource $resource )
$path string The Puli path.
$resource Puli\Repository\Api\Resource\FilesystemResource The resource to add.

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

public clear ( )

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

public contains ( $query, $language = 'glob' )

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

Turns a reference into a resource.
protected createResource ( string $path, string | null $reference ) : Puli\Repository\Api\Resource\PuliResource
$path string The Puli path.
$reference string | null The reference.
Результат Puli\Repository\Api\Resource\PuliResource The resource.

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

public find ( $query, $language = 'glob' )

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

Writes the JSON file.
protected flush ( )

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

public get ( $path )

getReferencesForGlob() абстрактный защищенный Метод

Each reference returned by this method can be: * null * a link starting with @ * an absolute filesystem path The keys of the returned array are Puli paths. Their order is undefined. The flag STOP_ON_FIRST may be used to stop the search at the first result.
abstract protected getReferencesForGlob ( string $glob, integer $flags ) : string[] | null[]
$glob string The glob.
$flags integer A bitwise combination of the flag constants in this class.
Результат string[] | null[] A one-level array of references with Puli paths as keys.

getReferencesForPath() абстрактный защищенный Метод

Each reference returned by this method can be: * null * a link starting with @ * an absolute filesystem path The result has either one entry or none, if no path was found. The key of the single entry is the path passed to this method.
abstract protected getReferencesForPath ( string $path ) : string[] | null[]
$path string The Puli path.
Результат string[] | null[] A one-level array of references with Puli paths as keys. The array has at most one entry.

getReferencesForRegex() абстрактный защищенный Метод

Each reference returned by this method can be: * null * a link starting with @ * an absolute filesystem path The keys of the returned array are Puli paths. Their order is undefined. The flag STOP_ON_FIRST may be used to stop the search at the first result.
abstract protected getReferencesForRegex ( string $staticPrefix, string $regex, integer $flags ) : string[] | null[]
$staticPrefix string The static prefix of all Puli paths matching the regular expression.
$regex string The regular expression.
$flags integer A bitwise combination of the flag constants in this class.
Результат string[] | null[] A one-level array of references with Puli paths as keys.

getReferencesInDirectory() абстрактный защищенный Метод

Each reference returned by this method can be: * null * a link starting with @ * an absolute filesystem path The keys of the returned array are Puli paths. Their order is undefined. The flag STOP_ON_FIRST may be used to stop the search at the first result.
abstract protected getReferencesInDirectory ( string $path, integer $flags ) : string[] | null[]
$path string The Puli path.
$flags integer A bitwise combination of the flag constants in this class.
Результат string[] | null[] A one-level array of references with Puli paths as keys.

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

public hasChildren ( $path )

insertReference() абстрактный защищенный Метод

The path reference can be: * a link starting with @ * an absolute filesystem path
abstract protected insertReference ( string $path, string | null $reference )
$path string The Puli path.
$reference string | null The path reference.

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

Returns whether a reference contains an absolute or relative filesystem path.
protected isFilesystemReference ( string $reference ) : boolean
$reference string The reference.
Результат boolean Whether the reference contains a filesystem path.

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

Returns whether a reference contains a link.
protected isLinkReference ( string $reference ) : boolean
$reference string The reference.
Результат boolean Whether the reference contains a link.

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

public listChildren ( $path )

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

Loads the JSON file.
protected load ( )

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

Logs a message.
protected log ( mixed $level, string $message )
$level mixed One of the level constants in {@link LogLevel}.
$message string The message.

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

Logs a warning that a reference could not be found.
protected logReferenceNotFound ( string $path, string $reference, string $absoluteReference )
$path string The Puli path of a path mapping.
$reference string The reference that was not found.
$absoluteReference string The absolute filesystem path of the reference.

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

public remove ( $query, $language = 'glob' )

removeReferences() абстрактный защищенный Метод

Removes all path references matching the given glob from the JSON file.
abstract protected removeReferences ( string $glob )
$glob string The glob for a list of Puli paths.

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

public setLogger ( Psr\Log\LoggerInterface $logger = null )
$logger Psr\Log\LoggerInterface

Описание свойств

$baseDirectory защищенное свойство

protected string $baseDirectory
Результат string

$json защищенное свойство

protected array $json
Результат array