Modules/Groupware/Files/File/Facade.php

Show: inherited
Table of Contents

\Conjoon_Modules_Groupware_Files_File_Facade

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).

Parent(s)
\Conjoon_Db_LobAccess_StorageMediator
Author
Thorsten Suckow-Homberg  

Properties

Propertyprotected  $_dbLobAccess= 'null'
Default valuenullDetails
Type
n/a
Inherited_from
\Conjoon_Db_LobAccess_StorageMediator::$$_dbLobAccess  
Propertyprotected  $_fileLobAccess= 'null'
Default valuenullDetails
Type
n/a
Inherited_from
\Conjoon_Db_LobAccess_StorageMediator::$$_fileLobAccess  
Propertyprivate\Conjoon_Modules_Groupware_Files_File_Model_File  $_fileModel= 'null'

Default valuenullDetails
Type
\Conjoon_Modules_Groupware_Files_File_Model_File
Propertyprivate\Conjoon_Modules_Groupware_Files_File_Facade  $_instance= 'null'
static

Default valuenullDetails
Type
\Conjoon_Modules_Groupware_Files_File_Facade

Methods

methodprivate__clone( ) : void

methodprivate__construct( ) : void

methodprotected_addLobFromPathToDb(  $data ) : void
inherited

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

Inherited from: \Conjoon_Db_LobAccess_StorageMediator::_addLobFromPathToDb()
Parameters
Name Type Description
$data
methodprotected_addLobFromResourceToDb(  $data ) : void
inherited

Helper 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.

Parameters
Name Type Description
$data
methodprivate_createFileObject( int $id, string $key, string $name, string $mimeType, int $groupwareFilesFoldersId ) : \Conjoon_Modules_Groupware_Files_File

Helper function for creating a Conjoon_Modules_Groupware_Files_File

Parameters
Name Type Description
$id int
$key string
$name string
$mimeType string
$groupwareFilesFoldersId int
Returns
Type Description
\Conjoon_Modules_Groupware_Files_File
methodprotected_createFolder( array $data ) : string | null
inherited

Helper function for creating a folder.

Inherited from: \Conjoon_Db_LobAccess_StorageMediator::_createFolder()

$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
inherited

Creates a lob.

Inherited from: \Conjoon_Db_LobAccess_StorageMediator::_createLob()

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

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
inherited

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

Inherited from: \Conjoon_Db_LobAccess_StorageMediator::_generateLobKey()
Parameters
Name Type Description
$data array
Returns
Type Description
string
methodprotected_generateStorageContainerString( array $data ) : string
inherited

Computes 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()
Parameters
Name Type Description
$data array
Returns
Type Description
string
methodprotected_getLobStorageBasePath( ) : string | null

Returns the file storage base path

Returns
Type Description
string | null
methodprotected_isFileSystemUsedForLobs( ) : bool

Returns true if LOBs should be stored in the filesystem.

Returns
Type Description
bool
methodpublicgetFileDownloadDataForUserId( integer $id, mixed $key, \inter $userId ) : array

Returns 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.

Parameters
Name Type Description
$id integer
$key mixed
$userId \inter
Returns
Type Description
array an assoc array with the keys "name", "mimeType" and "content", or null if item is not available.
Throws
Exception Description
\InvalidArgumentException
methodpublicgetInstance( ) : void
static

methodpublicgetLobContentWithData( array $data ) : array | null
inherited

Returns 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.

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
methodpublicisFileDownloadableForUserId( integer $id, integer $userId ) : boolean

Returns true if the user may download the file with the specified id, otherwise false.

Parameters
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

Returns
Type Description
boolean true if he may download the file, otherwise false
Throws
Exception Description
\InvalidArgumentException
methodpublicmoveFileToFolderForUserId( string $path, int $folderId, int $userId, string $name, string $type ) : \Conjoon_Modules_Groupware_Files_File

Tries to copy the contents of the specified file found under $path to the specified folder id.

Parameters
Name Type Description
$path string
$folderId int
$userId int
$name string
$type string
Returns
Type Description
\Conjoon_Modules_Groupware_Files_File if the file was successfully created, otherwise null
Throws
Exception Description
\InvalidArgumentException
methodpublicsetAccessors( \Conjoon_File_LobAccess $fileLobAccess, \Conjoon_Data_LobAccess $dbLobAccess ) : void
inherited

Sets the accessors for this class

Inherited from: \Conjoon_Db_LobAccess_StorageMediator::setAccessors()
Parameters
Name Type Description
$fileLobAccess \Conjoon_File_LobAccess
$dbLobAccess \Conjoon_Data_LobAccess
Documentation was generated by DocBlox 0.18.1.