class WritableFileSystemStorage extends FileSystemStorage implements WritableStorageInterface (View source)

A resource storage based on the (local) file system

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

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)

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

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.

importResource(string|resource $source, string $collectionName)

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

importResourceFromContent(string $content, string $collectionName)

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

bool
deleteResource(PersistentResource $resource)

Deletes the storage data related to the given PersistentResource object

importTemporaryFile(string $temporaryPathAndFileName, string $collectionName)

Imports the given temporary file into the storage and creates the new resource object.

void
moveTemporaryFileToFinalDestination(string $temporaryFile, string $finalTargetPathAndFilename)

Move a temporary file to the final destination, creating missing path segments on the way.

void
fixFilePermissions(string $pathAndFilename)

Fixes the permissions as needed for Flow to run fine in web and cli context.

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

Exceptions

Exception

string getName()

Returns the instance name of this storage

Return Value

string

resource|false getStreamByResource(PersistentResource $resource)

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

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"

PersistentResource importResource(string|resource $source, string $collectionName)

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

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

Parameters

string|resource $source

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

string $collectionName

Name of the collection the new PersistentResource belongs to

Return Value

PersistentResource

A resource object representing the imported resource

Exceptions

Exception

PersistentResource importResourceFromContent(string $content, string $collectionName)

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

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

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

string $collectionName

Name of the collection the new PersistentResource belongs to

Return Value

PersistentResource

A resource object representing the imported resource

Exceptions

Exception

bool deleteResource(PersistentResource $resource)

Deletes the storage data related to the given PersistentResource object

Parameters

PersistentResource $resource

The PersistentResource to delete the storage data of

Return Value

bool

true if removal was successful

protected PersistentResource importTemporaryFile(string $temporaryPathAndFileName, string $collectionName)

Imports the given temporary file into the storage and creates the new resource object.

Note: the temporary file is (re-)moved by this method.

Parameters

string $temporaryPathAndFileName
string $collectionName

Return Value

PersistentResource

Exceptions

Exception

protected void moveTemporaryFileToFinalDestination(string $temporaryFile, string $finalTargetPathAndFilename)

Move a temporary file to the final destination, creating missing path segments on the way.

Parameters

string $temporaryFile
string $finalTargetPathAndFilename

Return Value

void

Exceptions

Exception

protected void fixFilePermissions(string $pathAndFilename)

Fixes the permissions as needed for Flow to run fine in web and cli context.

Parameters

string $pathAndFilename

Return Value

void