class PackageStorage extends FileSystemStorage (View source)

A resource storage which stores and retrieves resources from active Flow packages.

Properties

protected string $name

Name which identifies this resource storage

from  FileSystemStorage
protected string $path

The path (in a filesystem) where resources are stored

from  FileSystemStorage
protected Environment $environment from  FileSystemStorage
protected ResourceManager $resourceManager from  FileSystemStorage
protected ResourceRepository $resourceRepository from  FileSystemStorage
protected PackageManager $packageManager

Methods

__construct(string $name, array $options = [])

Constructor

void
initializeObject()

Initializes this resource storage

string
getName()

Returns the instance name of this storage

resource|false
getStreamByResource(PersistentResource $resource)

Because we cannot store persistent resources in a PackageStorage, this method always returns false.

resource|false
getStreamByResourcePath(string $relativePath)

Returns a stream handle which can be used internally to open / copy the given resource stored in this storage.

StorageObject>
getObjects()

Retrieve all Objects stored in this storage.

StorageObject>
getObjectsByCollection(CollectionInterface $collection)

Retrieve all Objects stored in this storage, filtered by the given collection name

string
getStoragePathAndFilenameByHash(string $sha1Hash)

Determines and returns the absolute path and filename for a storage file identified by the given SHA1 hash.

StorageObject>
getObjectsByPathPattern(string $pattern)

Return all Objects stored in this storage filtered by the given directory / filename pattern

createStorageObject(string $resourcePathAndFilename, FlowPackageInterface $resourcePackage)

Create a storage object for the given static resource path.

string
prepareRelativePublicationPath(string $objectPath, string $packageKey, string $packageResourcePath)

Prepares a relative publication path for a package resource.

string[]
getPublicResourcePaths()

Returns the absolute paths of public resources directories of all active packages.

Details

__construct(string $name, array $options = [])

Constructor

Parameters

string $name

Name of this storage instance, according to the resource settings

array $options

Options for this storage

Exceptions

Exception

void initializeObject()

Initializes this resource storage

Return Value

void

string getName()

Returns the instance name of this storage

Return Value

string

resource|false getStreamByResource(PersistentResource $resource)

Because we cannot store persistent resources in a PackageStorage, this method always returns false.

Parameters

PersistentResource $resource

The resource stored in this storage

Return Value

resource|false

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

resource|false getStreamByResourcePath(string $relativePath)

Returns a stream handle which can be used internally to open / copy the given resource stored in this storage.

Parameters

string $relativePath

A path relative to the storage root, for example "MyFirstDirectory/SecondDirectory/Foo.css"

Return Value

resource|false

A URI (for example the full path and filename) leading to the resource file or false if it does not exist

StorageObject> getObjects()

Retrieve all Objects stored in this storage.

Return Value

StorageObject>

StorageObject> getObjectsByCollection(CollectionInterface $collection)

Retrieve all Objects stored in this storage, filtered by the given collection name

Parameters

CollectionInterface $collection

Return Value

StorageObject>

protected string getStoragePathAndFilenameByHash(string $sha1Hash)

Determines and returns the absolute path and filename for a storage file identified by the given SHA1 hash.

This function assures a nested directory structure in order to avoid thousands of files in a single directory which may result in performance problems in older file systems such as ext2, ext3 or NTFS.

Parameters

string $sha1Hash

The SHA1 hash identifying the stored resource

Return Value

string

The path and filename, for example "/var/www/mysite.com/Data/Persistent/c/8/2/8/c828d0f88ce197be1aff7cc2e5e86b1244241ac6"

StorageObject> getObjectsByPathPattern(string $pattern)

Return all Objects stored in this storage filtered by the given directory / filename pattern

Parameters

string $pattern

A glob compatible directory / filename pattern

Return Value

StorageObject>

protected StorageObject createStorageObject(string $resourcePathAndFilename, FlowPackageInterface $resourcePackage)

Create a storage object for the given static resource path.

Parameters

string $resourcePathAndFilename
FlowPackageInterface $resourcePackage

Return Value

StorageObject

protected string prepareRelativePublicationPath(string $objectPath, string $packageKey, string $packageResourcePath)

Prepares a relative publication path for a package resource.

Parameters

string $objectPath
string $packageKey
string $packageResourcePath

Return Value

string

string[] getPublicResourcePaths()

Returns the absolute paths of public resources directories of all active packages.

This method is used directly by the FileSystemSymlinkTarget.

Return Value

string[]