class Collection implements CollectionInterface (View source)

A resource collection

Properties

protected string $name
protected StorageInterface $storage
protected TargetInterface $target
protected array $pathPatterns
protected ResourceRepository $resourceRepository

Methods

__construct(string $name, StorageInterface $storage, TargetInterface $target, array $pathPatterns)

Constructor

string
getName()

Returns the name of this collection

getStorage()

Returns the storage used for this collection

getTarget()

Returns the publication target defined for this collection

importResource(string|resource $source)

Imports a resource (file) from the given URI or PHP resource stream into this collection.

importResourceFromContent(string $content)

Imports a resource from the given string content into this collection.

void
publish()

Publishes the whole collection to the corresponding publishing target

StorageObject>
getObjects(callable $callback = null)

Returns all internal data objects of the storage attached to this collection.

resource|bool
getStreamByResource(PersistentResource $resource)

Returns a stream handle of the given persistent resource which allows for opening / copying the resource's data. Note that this stream handle may only be used read-only.

Details

__construct(string $name, StorageInterface $storage, TargetInterface $target, array $pathPatterns)

Constructor

Parameters

string $name

User-space name of this collection, as specified in the settings

StorageInterface $storage

The storage for data used in this collection

TargetInterface $target

The publication target for this collection

array $pathPatterns

Glob patterns for paths to consider – only supported by specific storages

string getName()

Returns the name of this collection

Return Value

string

StorageInterface getStorage()

Returns the storage used for this collection

Return Value

StorageInterface

TargetInterface getTarget()

Returns the publication target defined for this collection

Return Value

TargetInterface

PersistentResource importResource(string|resource $source)

Imports a resource (file) from the given URI or PHP resource stream into this collection.

On a successful import this method returns a PersistentResource object representing the newly imported persistent resource.

Note that this collection must have a writable storage in order to import resources.

Parameters

string|resource $source

The URI (or local path and filename) or the PHP resource stream to import the resource from

Return Value

PersistentResource

A resource object representing the imported resource

Exceptions

Exception

PersistentResource importResourceFromContent(string $content)

Imports a resource from the given string content into this collection.

On a successful import this method returns a PersistentResource object representing the newly imported persistent resource.

Note that this collection must have a writable storage in order to import resources.

The specified filename will be used when presenting the resource to a user. Its file extension is important because the resource management will derive the IANA Media Type from it.

Parameters

string $content

The actual content to import

Return Value

PersistentResource

A resource object representing the imported resource

Exceptions

Exception

void publish()

Publishes the whole collection to the corresponding publishing target

Return Value

void

StorageObject> getObjects(callable $callback = null)

Returns all internal data objects of the storage attached to this collection.

Parameters

callable $callback

Function called after each object

Return Value

StorageObject>

resource|bool getStreamByResource(PersistentResource $resource)

Returns a stream handle of the given persistent resource which allows for opening / copying the resource's data. Note that this stream handle may only be used read-only.

Parameters

PersistentResource $resource

The resource to retrieve the stream for

Return Value

resource|bool

The resource stream or false if the stream could not be obtained