Db/LobAccess/StorageMediator.php

Show: inherited
Table of Contents

\Conjoon_Db_LobAccess_StorageMediator

Package: Default

A storage mediator is responsible for determining whether to store lobs in the database or in the file system. It takes care of processing various operations related to lobs such as retrieving their content and properly storing them, while maintaining relations between the db data and the lob itself, no matter if it has been saved in the filesystem or the db.

While configuring the system is up to the server administrator, a mediator is able to provide fallbacks if the used instances of Conjoon_File_LobAccess and Conjoon_Db_LobAccess have been implemented properly: As long as the hint for the storage_container maintains valid, lob data can be retrieved from the filesystem even if the application's configuration is set to storing the lobs in the database (this goes for lobs that have been saved before configuration changed).

Children
\Conjoon_Modules_Groupware_Files_File_Facade
Author
Thorsten Suckow-Homberg  

Properties

Propertyprotected  $_dbLobAccess= 'null'
Default valuenullDetails
Type
n/a
Propertyprotected  $_fileLobAccess= 'null'
Default valuenullDetails
Type
n/a

Methods

methodprotected_addLobFromPathToDb(  $data ) : void

Helper function for adding a Lob from a file path to the db.

Parameters
Name Type Description
$data
methodprotected_addLobFromResourceToDb(  $data ) : void

Helper function for adding a Lob from a resource to the db.

When caling this, you should have already validated that the resource property from data is a resource.

Parameters
Name Type Description
$data
methodprotected_createFolder( array $data ) : string | null

Helper function for creating a folder.

$data must have lobStorageBasePath and storageContainer available.

Parameters
Name Type Description
$data array
Returns
Type Description
string | null the full path name for a lob to be stored if creating the dir was successfull (or the dir already existed), otherwise null
Details
See
\_createFolderImpl  
methodprotected_createLob( array $data, bool $isPath = false, bool | bool $move = false ) : array | null

Creates a lob.

Additional parameters will be added to the array during processing, such as the generated key for the lob.

Parameters
Name Type Description
$data array

An associative array with at least the following key/value pairs: - resource The resource to fetch the content from. This can either be a native resource or a string. If $isPath is set to true, the string will be treatened as a path and the contents from the file found under this path will be read out/copied/moved.

$isPath bool

Whether to treat "resource" as a file path.

$move bool | bool

if §isPath is set to true,

Returns
Type Description
array | null an array with the submitted data, along with additional properties applied during runtime, or null on failure. The $result will be stored in the variable $dbResult
Throws
Exception Description
\Conjoon_Data_Exception
methodprotected_generateFileNameStringForLob( array $data ) : string
abstract

Computes a file name based on the given data in $data

Parameters
Name Type Description
$data array
Returns
Type Description
string
methodprotected_generateLobKey( array $data ) : string

Computes a unique key for teh LOB name based on the specified data in $data

Parameters
Name Type Description
$data array
Returns
Type Description
string
methodprotected_generateStorageContainerString( array $data ) : string

Computes a storage container string which should be safe to use for the hosts filesystem based on the specified data in $data

Parameters
Name Type Description
$data array
Returns
Type Description
string
methodprotected_getLobStorageBasePath( ) : string | null
abstract

Returns the file storage base path

Returns
Type Description
string | null
methodprotected_isFileSystemUsedForLobs( ) : bool
abstract

Returns true if LOBs should be stored in the filesystem.

Returns
Type Description
bool
methodpublicgetLobContentWithData( array $data ) : array | null

Returns the complete lob data for the specified id and key.

The properties key and id have to be set in the passed array.

Parameters
Name Type Description
$data array
Returns
Type Description
array | null If a call to this method is successfull, the returned property "resource" will be set with the lob's content
Throws
Exception Description
\Conjoon_Data_Exception
methodpublicsetAccessors( \Conjoon_File_LobAccess $fileLobAccess, \Conjoon_Data_LobAccess $dbLobAccess ) : void

Sets the accessors for this class

Parameters
Name Type Description
$fileLobAccess \Conjoon_File_LobAccess
$dbLobAccess \Conjoon_Data_LobAccess
Documentation was generated by DocBlox 0.18.1.