Modules/Groupware/Files/File/Facade.php
\Conjoon_Modules_Groupware_Files_File_Facade
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).
- Parent(s)
- \Conjoon_Db_LobAccess_StorageMediator
- Author
- Thorsten Suckow-Homberg
Properties

$_dbLobAccess= 'null'
nullDetails- Type
- n/a
- Inherited_from
- \Conjoon_Db_LobAccess_StorageMediator::$$_dbLobAccess

$_fileLobAccess= 'null'
nullDetails- Type
- n/a
- Inherited_from
- \Conjoon_Db_LobAccess_StorageMediator::$$_fileLobAccess
Methods

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

_addLobFromResourceToDb(
$data
)
:
voidHelper function for adding a Lob from a resource to the db.
Inherited from: \Conjoon_Db_LobAccess_StorageMediator::_addLobFromResourceToDb()When caling this, you should have already validated that the resource property from data is a resource.
| Name | Type | Description |
|---|---|---|
| $data |

_createFileObject(
int $id, string $key, string $name, string $mimeType, int $groupwareFilesFoldersId
)
:
\Conjoon_Modules_Groupware_Files_FileHelper function for creating a Conjoon_Modules_Groupware_Files_File
| Name | Type | Description |
|---|---|---|
| $id | int | |
| $key | string | |
| $name | string | |
| $mimeType | string | |
| $groupwareFilesFoldersId | int |
| Type | Description |
|---|---|
| \Conjoon_Modules_Groupware_Files_File |

_createFolder(
array $data
)
:
string | nullHelper function for creating a folder.
Inherited from: \Conjoon_Db_LobAccess_StorageMediator::_createFolder()$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 | null
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
Inherited from: \Conjoon_Db_LobAccess_StorageMediator::_generateLobKey()| 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
Inherited from: \Conjoon_Db_LobAccess_StorageMediator::_generateStorageContainerString()| Name | Type | Description |
|---|---|---|
| $data | array |
| Type | Description |
|---|---|
| string |

_getFileModel(
)
:
\Conjoon_Modules_Groupware_Files_File_Model_File| Type | Description |
|---|---|
| \Conjoon_Modules_Groupware_Files_File_Model_File |

_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 |

getFileDownloadDataForUserId(
integer $id, mixed $key, \inter $userId
)
:
arrayReturns download data for the required file, i.e. mime type, name and content. The data will be returned in an associative array and is already prepared for sending to the client, i.e. the content to send has already been decoded if necessary.
| Name | Type | Description |
|---|---|---|
| $id | integer | |
| $key | mixed | |
| $userId | \inter |
| Type | Description |
|---|---|
| array | an assoc array with the keys "name", "mimeType" and "content", or null if item is not available. |
| Exception | Description |
|---|---|
| \InvalidArgumentException |

getLobContentWithData(
array $data
)
:
array | nullReturns the complete lob data for the specified id and key.
Inherited from: \Conjoon_Db_LobAccess_StorageMediator::getLobContentWithData()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 |

isFileDownloadableForUserId(
integer $id, integer $userId
)
:
booleanReturns true if the user may download the file with the specified id, otherwise false.
| Name | Type | Description |
|---|---|---|
| $id | integer | The id of the file to download |
| $userId | integer | The id of the user who requests the file being downloaded |
| Type | Description |
|---|---|
| boolean | true if he may download the file, otherwise false |
| Exception | Description |
|---|---|
| \InvalidArgumentException |

moveFileToFolderForUserId(
string $path, int $folderId, int $userId, string $name, string $type
)
:
\Conjoon_Modules_Groupware_Files_FileTries to copy the contents of the specified file found under $path to the specified folder id.
| Name | Type | Description |
|---|---|---|
| $path | string | |
| $folderId | int | |
| $userId | int | |
| $name | string | |
| $type | string |
| Type | Description |
|---|---|
| \Conjoon_Modules_Groupware_Files_File | if the file was successfully created, otherwise null |
| Exception | Description |
|---|---|
| \InvalidArgumentException |

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