PHP Интерфейс Puli\Repository\Api\Resource\PuliResource

Resources are objects which can be stored in a resource repository. Resources have a path, under which they are stored in the repository. Depending on the implementation, resources may offer additional functionality: * Resources that are similar to files in that they have a body and a size should implement {@link BodyResource}. Resources can be attached to a repository by calling {@link attachTo()}. They can be detached again by calling {@link detach()}. Use {@link isAttached()} to find out whether a resource is attached and {@link getRepository()} to obtain the attached repository. You can create a reference to a resource by calling {@link createReference()}. References can have different paths than the resource they are referencing. Otherwise, they are identical to the referenced resource. Use {@link isReference()} to check whether a resource is a reference. You can call {@link getRepositoryPath()} to retrieve the path of the referenced resource. If you implement a custom resource, let your test extend {@link AbstractResourceTest} to make sure your resource satisfies the constraints of the interface. Extend {@link GenericResource} if you want to avoid reimplementing basic functionality.
С версии: 1.0
Автор: Bernhard Schussek ([email protected])
Наследование: extends Serializabl\Serializable
Показать файл Открыть проект Примеры использования интерфейса

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

Метод Описание
attachTo ( Puli\Repository\Api\ResourceRepository $repo, string | null $path = null ) Attaches the resource to a repository.
createReference ( string $path ) : static Creates a reference to the resource.
detach ( ) Detaches the resource from the repository.
getChild ( string $relPath ) : Puli\Repository\Api\Resource\PuliResource Returns the child resource with the given relative path.
getMetadata ( ) : ResourceMetadata Returns metadata about a resource.
getName ( ) : string | null Returns the name of the resource.
getPath ( ) : string | null Returns the path of the resource.
getRepository ( ) : Puli\Repository\Api\ResourceRepository | null Returns the repository that the resource is attached to.
getRepositoryPath ( ) : string | null Returns the path of the resource in the repository.
getVersions ( ) : VersionList Returns the versions of this resource.
hasChild ( string $relPath ) : boolean Returns whether the child resource with the given relative path exists.
hasChildren ( ) : boolean Returns whether the resource has child resources.
isAttached ( ) : boolean Returns whether the resource is attached to a repository.
isReference ( ) : boolean Returns whether a resource is a reference.
listChildren ( ) : Puli\Repository\Api\ResourceCollection Lists the child resources of the resources.

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

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

You can optionally change the path of the resource by passing it in the second argument. Beware that this may break the resource if it is still referenced by another repository. Hence you should clone resources that are attached to another repository before attaching them: php if ($resource->isAttached()) { $resource = clone $resource; } $resource->attachTo($repo, '/path/in/repo');
public attachTo ( Puli\Repository\Api\ResourceRepository $repo, string | null $path = null )
$repo Puli\Repository\Api\ResourceRepository The repository.
$path string | null The path of the resource in the repository. If not passed, the resource will be attached to it current path.

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

References are identical for their referenced resource except for their path. The path of the referenced resource can be obtained by calling {@link getRepositoryPath()}: php $resource = new MyResource('/path'); $reference = $resource->createReference('/reference'); $reference->getPath(); "/reference" $reference->getRepositoryPath(); "/path" Use {@link isReference()} to find out whether a resource is a reference.
public createReference ( string $path ) : static
$path string The path of the reference.
Результат static The reference.

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

After calling this method, {@link isAttached()} returns false. The method {@link getRepository()} should return null after detaching. Neither the path nor the repository path of the resource should be modified when detaching.
public detach ( )

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

"." and ".." are supported as paths.
public getChild ( string $relPath ) : Puli\Repository\Api\Resource\PuliResource
$relPath string The relative resource path.
Результат Puli\Repository\Api\Resource\PuliResource The resource with the given path.

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

Returns metadata about a resource.
public getMetadata ( ) : ResourceMetadata
Результат ResourceMetadata The resource metadata.

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

The name is the last segment of the path returned by {@link getPath()}.
public getName ( ) : string | null
Результат string | null The name of the resource. If the resource has no path, `null` is returned.

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

For references created with {@link createReference()}, the path returned by this method is the reference path and not the actual repository path of the referenced resource. You should use {@link getRepositoryPath()} if you want to glob the repository for a resource.
public getPath ( ) : string | null
Результат string | null The path of the resource. If the resource has no path, `null` is returned.

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

Use {@link attachTo()} to attach a resource to a repository. The method {@link detach()} can be used to detach an attached resource.
public getRepository ( ) : Puli\Repository\Api\ResourceRepository | null
Результат Puli\Repository\Api\ResourceRepository | null The resource repository. If the resource is not attached to any repository, `null` is returned.

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

The repository path is the path that the resource is mapped to once attached to a repository. The result of this method is different from {@link getPath()} for resource references. PuliResource references return the path of the referenced resource here, while {@link getPath()} returns the path of the reference itself.
public getRepositoryPath ( ) : string | null
Результат string | null The repository path of the resource. If the resource has no repository path, `null` is returned.

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

Returns the versions of this resource.
public getVersions ( ) : VersionList
Результат Puli\Repository\Api\ChangeStream\VersionList The resource versions.

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

Returns whether the child resource with the given relative path exists.
public hasChild ( string $relPath ) : boolean
$relPath string The relative resource path.
Результат boolean Whether a resource with the given path exists.

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

Returns whether the resource has child resources.
public hasChildren ( ) : boolean
Результат boolean Returns `true` if the resource has child resources.

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

Resources can be attached to a repository with {@link attachTo()}. The method {@link getRepository()} returns the attached repository.
public isAttached ( ) : boolean
Результат boolean Whether the resource is attached to a repository.

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

References are created by calling {@link createReference()}.
public isReference ( ) : boolean
Результат boolean Whether the resource is a reference.

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

Lists the child resources of the resources.
public listChildren ( ) : Puli\Repository\Api\ResourceCollection
Результат Puli\Repository\Api\ResourceCollection The child resources indexed by their names.