Db/LobAccess/StorageMediator.php
\Conjoon_Db_LobAccess_StorageMediator
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
Methods

_addLobFromPathToDb(
$data
)
:
voidHelper function for adding a Lob from a file path to the db.
| Name | Type | Description |
|---|---|---|
| $data |

_addLobFromResourceToDb(
$data
)
:
voidHelper 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.
| Name | Type | Description |
|---|---|---|
| $data |

_createFolder(
array $data
)
:
string | nullHelper function for creating a folder.
$data must have lobStorageBasePath and storageContainer available.
| Name | Type | Description |
|---|---|---|
| $data | array |
| 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 |
- See
- \_createFolderImpl

_createLob(
array $data, bool $isPath
=
false, bool | bool $move
=
false
)
:
array | nullCreates a lob.
Additional parameters will be added to the array during processing, such as the generated key for the lob.
| 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, |
| 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 |
| Exception | Description |
|---|---|
| \Conjoon_Data_Exception |

_generateFileNameStringForLob(
array $data
)
:
stringComputes a file name based on the given data in $data
| Name | Type | Description |
|---|---|---|
| $data | array |
| Type | Description |
|---|---|
| string |

_generateLobKey(
array $data
)
:
stringComputes a unique key for teh LOB name based on the specified data in $data
| Name | Type | Description |
|---|---|---|
| $data | array |
| Type | Description |
|---|---|
| string |

_generateStorageContainerString(
array $data
)
:
stringComputes a storage container string which should be safe to use for the hosts filesystem based on the specified data in $data
| Name | Type | Description |
|---|---|---|
| $data | array |
| Type | Description |
|---|---|
| string |

_getLobStorageBasePath(
)
:
string | nullReturns the file storage base path
| Type | Description |
|---|---|
| string | null |

_isFileSystemUsedForLobs(
)
:
boolReturns true if LOBs should be stored in the filesystem.
| Type | Description |
|---|---|
| bool |

getLobContentWithData(
array $data
)
:
array | nullReturns the complete lob data for the specified id and key.
The properties key and id have to be set in the passed array.
| Name | Type | Description |
|---|---|---|
| $data | array |
| Type | Description |
|---|---|
| array | null | If a call to this method is successfull, the returned property "resource" will be set with the lob's content |
| Exception | Description |
|---|---|
| \Conjoon_Data_Exception |

setAccessors(
\Conjoon_File_LobAccess $fileLobAccess, \Conjoon_Data_LobAccess $dbLobAccess
)
:
voidSets the accessors for this class
| Name | Type | Description |
|---|---|---|
| $fileLobAccess | \Conjoon_File_LobAccess | |
| $dbLobAccess | \Conjoon_Data_LobAccess |