PHP Class Airship\Cabin\Bridge\Blueprint\Files

Manage user-provided files.
Inheritance: extends BlueprintGear
Afficher le fichier Open project: paragonie/airship Class Usage Examples

Protected Properties

Свойство Type Description
$finfo finfo

Méthodes publiques

Méthode Description
__construct ( Database $db ) Files constructor.
createDirectory ( integer | null $parent = null, string $cabin = '', string $dirName = '' ) : boolean Create a new directory
deleteDir ( string $cabin, string $root, string $subdirectory ) : boolean Delete a directory
deleteFile ( array $fileInfo ) : boolean Delete a file
dirExists ( null $parent = null, string $cabin = '', string $dirName = '' ) : boolean Does the directory already exist?
ensureDirExists ( string $absolutePath, string $cabin = 'Hull' ) : boolean Programmatically ensure that the directory exists.
getChildrenOf ( mixed $directoryId = null, string $cabin = '' ) : array Get all of the directories beneath the current one
getContentsTree ( string $cabin, string $base, string $thisDir ) : array Get the contents of a given cabin/directory, recursively
getDirectoryCabin ( integer $directoryId ) : string Given a directory ID, get its cabin.
getDirectoryId ( array $parts, string $cabin ) : integer Get a directory ID, should it exist.
getDirectoryTree ( string $cabin = '', string $rootDir = '', string $ignore = '', string $pieces = '' ) : array Build a recursive directory tree
getFileInfo ( string $cabin = '', array $path = null, string $filename = '' ) : array Get detailed file information
getFilesCabin ( integer $fileId ) : string Given a file ID, get its Cabin
getFilesInDirectory ( null $directoryId = null, string $cabin = '' ) : array Get all of the directories beneath the current one
getMimeType ( string $filePath ) : string Get the MIME type for a given file.
isValidName ( string $name ) : boolean Does this file have a valid filename?
isolateFiles ( array $files = [] ) : array Turn PHP's native $_FILES mess into a sane array
moveDir ( string $cabin, string $root, string $subdirectory, array $post = [] ) : boolean Move/rename a directory
moveFile ( array $fileInfo, array $post, string $cabin ) : boolean Move/rename a file
processUpload ( integer | null $directoryId = null, string $cabin = '', array $file = [], array $attribution = [] ) : array Process an upload. Either it returns an array with useful data, OR it throws an UploadError

Méthodes protégées

Méthode Description
getContentsIterative ( integer $parent, string $path, string $cabin ) : array Get a list of all the files in a directory.
getUniqueFileName ( string $name, string $ext, integer | null $directoryId = null, string $cabin = '' ) : string Get a string that doesn't get exist in the DB

Private Methods

Méthode Description
moveUploadedFile ( string $tmp_name ) : string This method is private to avoid it from being accessed outside of the trusted methods (which handle validation). Don't change it.
recursiveDelete ( integer $directory, string $cabin ) : boolean Recursively delete everything in a specific directory

Method Details

__construct() public méthode

Files constructor.
public __construct ( Database $db )
$db Database

createDirectory() public méthode

Create a new directory
public createDirectory ( integer | null $parent = null, string $cabin = '', string $dirName = '' ) : boolean
$parent integer | null
$cabin string
$dirName string
Résultat boolean

deleteDir() public méthode

Delete a directory
public deleteDir ( string $cabin, string $root, string $subdirectory ) : boolean
$cabin string
$root string
$subdirectory string
Résultat boolean

deleteFile() public méthode

Delete a file
public deleteFile ( array $fileInfo ) : boolean
$fileInfo array
Résultat boolean

dirExists() public méthode

Does the directory already exist?
public dirExists ( null $parent = null, string $cabin = '', string $dirName = '' ) : boolean
$parent null
$cabin string
$dirName string
Résultat boolean

ensureDirExists() public méthode

Programmatically ensure that the directory exists.
public ensureDirExists ( string $absolutePath, string $cabin = 'Hull' ) : boolean
$absolutePath string
$cabin string
Résultat boolean

getChildrenOf() public méthode

Get all of the directories beneath the current one
public getChildrenOf ( mixed $directoryId = null, string $cabin = '' ) : array
$directoryId mixed (usually an integer, sometimes null)
$cabin string
Résultat array

getContentsIterative() protected méthode

Get a list of all the files in a directory.
protected getContentsIterative ( integer $parent, string $path, string $cabin ) : array
$parent integer
$path string
$cabin string
Résultat array

getContentsTree() public méthode

Get the contents of a given cabin/directory, recursively
public getContentsTree ( string $cabin, string $base, string $thisDir ) : array
$cabin string
$base string
$thisDir string
Résultat array

getDirectoryCabin() public méthode

Given a directory ID, get its cabin.
public getDirectoryCabin ( integer $directoryId ) : string
$directoryId integer
Résultat string

getDirectoryId() public méthode

Get a directory ID, should it exist.
public getDirectoryId ( array $parts, string $cabin ) : integer
$parts array
$cabin string
Résultat integer

getDirectoryTree() public méthode

Build a recursive directory tree
public getDirectoryTree ( string $cabin = '', string $rootDir = '', string $ignore = '', string $pieces = '' ) : array
$cabin string
$rootDir string
$ignore string
$pieces string
Résultat array

getFileInfo() public méthode

Get detailed file information
public getFileInfo ( string $cabin = '', array $path = null, string $filename = '' ) : array
$cabin string
$path array
$filename string
Résultat array

getFilesCabin() public méthode

Given a file ID, get its Cabin
public getFilesCabin ( integer $fileId ) : string
$fileId integer
Résultat string

getFilesInDirectory() public méthode

Get all of the directories beneath the current one
public getFilesInDirectory ( null $directoryId = null, string $cabin = '' ) : array
$directoryId null
$cabin string
Résultat array

getMimeType() public méthode

Get the MIME type for a given file.
public getMimeType ( string $filePath ) : string
$filePath string
Résultat string

getUniqueFileName() protected méthode

Get a string that doesn't get exist in the DB
protected getUniqueFileName ( string $name, string $ext, integer | null $directoryId = null, string $cabin = '' ) : string
$name string
$ext string
$directoryId integer | null
$cabin string
Résultat string

isValidName() public méthode

Does this file have a valid filename?
public isValidName ( string $name ) : boolean
$name string
Résultat boolean

isolateFiles() public méthode

USAGE: $result = $this->isolateFiles($_FILES['some_index']);
public isolateFiles ( array $files = [] ) : array
$files array
Résultat array

moveDir() public méthode

Move/rename a directory
public moveDir ( string $cabin, string $root, string $subdirectory, array $post = [] ) : boolean
$cabin string
$root string
$subdirectory string
$post array
Résultat boolean

moveFile() public méthode

Move/rename a file
public moveFile ( array $fileInfo, array $post, string $cabin ) : boolean
$fileInfo array
$post array
$cabin string
Résultat boolean

processUpload() public méthode

Process an upload. Either it returns an array with useful data, OR it throws an UploadError
public processUpload ( integer | null $directoryId = null, string $cabin = '', array $file = [], array $attribution = [] ) : array
$directoryId integer | null
$cabin string
$file array
$attribution array Who uploaded it?
Résultat array

Property Details

$finfo protected_oe property

protected finfo $finfo
Résultat finfo