AbstractFileStorage

Class AbstractFileStorage

category

System

package

Shared

subpackage

Storage

Methods

AbstractFileStorage constructor.

__construct(\WritableDirectory $storageDirectory) 

Arguments

$storageDirectory

\WritableDirectory

Create and Return the New Filename

_createAndReturnNewFilename(\FilenameStringType $existingFilename) : string

Checks whether the provided preferred filename already exists and generates one, with appending the next available number, which does not already exist.

Throws
\InvalidArgumentException

Arguments

$existingFilename

\FilenameStringType

The existing filename to change.

Response

string

The created filename

Validates the provided file.

_validateFile(\ExistingFile $sourceFile) : \AbstractFileStorage
abstract
Throws
\InvalidArgumentException

Arguments

$sourceFile

\ExistingFile

The file to validate.

Response

\AbstractFileStorage

Same instance for chained method calls.

Validates the provided filename.

_validateFilename(\FilenameStringType $filename) : \AbstractFileStorage
abstract
Throws
\InvalidArgumentException

Arguments

$filename

\FilenameStringType

The filename to validate.

Response

\AbstractFileStorage

Same instance for chained method calls.

Delete File

deleteFile(\FilenameStringType $filename) : \AbstractFileStorage

Deletes an existing file.

Arguments

$filename

\FilenameStringType

The file to delete.

Response

\AbstractFileStorage

Same instance for chained method calls.

File Exists

fileExists(\FilenameStringType $filename) : boolean

Checks if the provided file exists.

Arguments

$filename

\FilenameStringType

The filename of the file to be checked.

Response

boolean

Returns a file list for a directory.

getFileList(\WritableDirectory $directory, array $extensions = array()) : array

Arguments

$directory

\WritableDirectory

Directory to scan.

$extensions

array

File extensions (optional).

Response

array

Import File

importFile(\ExistingFile $sourceFile, \FilenameStringType $preferredFilename) : string

Saves an image to a writable directory.

Throws
\InvalidArgumentException

Arguments

$sourceFile

\ExistingFile

The source file to import.

$preferredFilename

\FilenameStringType

The preferred name of the file to be saved.

Response

string

The created filename

Rename File

renameFile(\FilenameStringType $oldName, \FilenameStringType $newName) : \AbstractFileStorage

Renames an existing image file.

Throws
\InvalidArgumentException

If a file with the preferred name already exists.

\InvalidArgumentException

If the file that should be renamed does not exists.

Arguments

$oldName

\FilenameStringType

The old name of the file.

$newName

\FilenameStringType

The new name of the file.

Response

\AbstractFileStorage

Same instance for chained method calls.

Properties

Storage Directory.

storageDirectory : \WritableDirectory
var

Type(s)

\WritableDirectory