PHP Class Contao\Dbafs

The class provides static methods to add, move, copy and delete resources as well as a method to synchronize the file system and the database. Usage: $file = Dbafs::addResource('files/james-wilson.jpg');
ファイルを表示 Open project: contao/core-bundle Class Usage Examples

Protected Properties

Property Type Description
$arrShouldBeSynchronized array Synchronize the database

Public Methods

Method Description
addResource ( string $strResource, boolean $blnUpdateFolders = true ) : FilesModel Adds a file or folder with its parent folders
copyResource ( string $strSource, string $strDestination ) : FilesModel Copies a file or folder to a new location
deleteResource ( string $strResource ) : null Removes a file or folder
moveResource ( string $strSource, string $strDestination ) : FilesModel Moves a file or folder to a new location
shouldBeSynchronized ( string $strPath ) : boolean Check if the current resource should be synchronized with the database
syncFiles ( ) : string Synchronize the file system with the database
updateFolderHashes ( mixed $varResource ) Update the hashes of all parent folders of a resource

Protected Methods

Method Description
isFileSyncExclude ( string $strPath ) : boolean Check if a file or folder is excluded from synchronization

Method Details

addResource() public static method

Adds a file or folder with its parent folders
public static addResource ( string $strResource, boolean $blnUpdateFolders = true ) : FilesModel
$strResource string The path to the file or folder
$blnUpdateFolders boolean If true, the parent folders will be updated
return FilesModel The files model

copyResource() public static method

Copies a file or folder to a new location
public static copyResource ( string $strSource, string $strDestination ) : FilesModel
$strSource string The source path
$strDestination string The target path
return FilesModel The files model

deleteResource() public static method

Removes a file or folder
public static deleteResource ( string $strResource ) : null
$strResource string The path to the file or folder
return null Explicitly return null

isFileSyncExclude() protected static method

Check if a file or folder is excluded from synchronization
protected static isFileSyncExclude ( string $strPath ) : boolean
$strPath string The relative path
return boolean True if the file or folder is excluded from synchronization

moveResource() public static method

Moves a file or folder to a new location
public static moveResource ( string $strSource, string $strDestination ) : FilesModel
$strSource string The source path
$strDestination string The target path
return FilesModel The files model

shouldBeSynchronized() public static method

Check if the current resource should be synchronized with the database
public static shouldBeSynchronized ( string $strPath ) : boolean
$strPath string The relative path
return boolean True if the current resource needs to be synchronized with the database

syncFiles() public static method

Synchronize the file system with the database
public static syncFiles ( ) : string
return string The path to the synchronization log file

updateFolderHashes() public static method

Update the hashes of all parent folders of a resource
public static updateFolderHashes ( mixed $varResource )
$varResource mixed A path or an array of paths to update

Property Details

$arrShouldBeSynchronized protected_oe static_oe property

Synchronize the database
protected static array $arrShouldBeSynchronized
return array