Documentation

FileManager extends AbstractHelper
in package
uses FileConfiguration

A base class for many Core classes to provide shared access to resources and common functions

Table of Contents

Constants

CONFIG_FILE  = "file.manager"

Properties

$baseFilePath  : string
$configs  : array<string, array<string|int, mixed>>
$site  : Site

Methods

configure()  : void
Override to handle any Helper specific configurations.
getAppConfiguration()  : array<string|int, mixed>
Provides a single instance of the global app configuration to all extenders of CoreObject
getBaseFilePath()  : string
getDirectoryContents()  : array<int, array<string, string>>
Provides an array of \pathinfo results for the files in the given directory
getDirectoryFiles()  : array<string|int, File>
Provides an array of \Pipit\Interfaces\File for a given directory
getDownloadableFile()  : void
Provides the specified \Interfaces\File as a downloadable attachment
getDownloadableFileByFileName()  : void
Provides the named file as a downloadable attachment
getFileFromFileName()  : SimpleFile
Provides a \Pipit\Interfaces\File for a given file name
getLogger()  : Logger
Provides a single instance of a configured Logger to all extenders of CoreObject
getSite()  : Site
Get the site associated with this Helper
processBase64File()  : string
removeFile()  : bool
Attempts to delete a file represented by a \Pipit\Interfaces\File implementation
removeFileByFileName()  : bool
Attempts to delete a file with the given file name
setSite()  : void
Set the site associated with this Helper
configurationFileExists()  : bool
Checks for the existence of a file with the given filename
createDirectory()  : void
Attempts to create a directory with the given name
getConfigurationFromFileName()  : array<string|int, mixed>
Retrieves a config array by its corresponding filename
checkFile()  : void
loadConfigurationFile()  : void
Loads and parses a php ini file into an array keyed by ini sections

Constants

CONFIG_FILE

private mixed CONFIG_FILE = "file.manager"

Properties

$baseFilePath

private string $baseFilePath

The directory path to store uploaded files

$configs

private array<string, array<string|int, mixed>> $configs = []

An array of configuration arrays

Methods

configure()

Override to handle any Helper specific configurations.

public configure(Site $site) : void
Parameters
$site : Site

An implementation of \Interfaces\Site

getAppConfiguration()

Provides a single instance of the global app configuration to all extenders of CoreObject

public getAppConfiguration() : array<string|int, mixed>
Return values
array<string|int, mixed>

getBaseFilePath()

public getBaseFilePath() : string
Return values
string

getDirectoryContents()

Provides an array of \pathinfo results for the files in the given directory

public getDirectoryContents([string $directoryPath = null ][, bool $filesOnly = false ]) : array<int, array<string, string>>
Parameters
$directoryPath : string = null

The directory to scan

$filesOnly : bool = false

Whether to exclude subdirectories from the results

Return values
array<int, array<string, string>>

getDirectoryFiles()

Provides an array of \Pipit\Interfaces\File for a given directory

public getDirectoryFiles([string $directoryPath = null ]) : array<string|int, File>
Parameters
$directoryPath : string = null

The directory whose files should be retrieved

Return values
array<string|int, File>

getDownloadableFile()

Provides the specified \Interfaces\File as a downloadable attachment

public getDownloadableFile(File $file) : void
Parameters
$file : File

An \Interfaces\File

getDownloadableFileByFileName()

Provides the named file as a downloadable attachment

public getDownloadableFileByFileName(string $fileName) : void
Parameters
$fileName : string

The name of the file to retrieve

getFileFromFileName()

Provides a \Pipit\Interfaces\File for a given file name

public getFileFromFileName(string $fileName) : SimpleFile
Parameters
$fileName : string

The name of the file to retrieve

Return values
SimpleFile

getLogger()

Provides a single instance of a configured Logger to all extenders of CoreObject

public getLogger() : Logger
Return values
Logger

processBase64File()

public processBase64File(string $encodedFile[, string $fileName = null ][, string $fileDirectory = null ]) : string
Parameters
$encodedFile : string

The base64 representation of the file data

$fileName : string = null

The fileName to create. Optional

$fileDirectory : string = null

The directory in which to create the file. Optional

Return values
string

The name of the created file

removeFile()

Attempts to delete a file represented by a \Pipit\Interfaces\File implementation

public removeFile(File $file) : bool
Parameters
$file : File

The File to delete

Return values
bool

Returns true on successful deletion

removeFileByFileName()

Attempts to delete a file with the given file name

public removeFileByFileName(string $fileName) : bool
Parameters
$fileName : string
Return values
bool

Returns true on successful deletion

setSite()

Set the site associated with this Helper

public setSite(Site $site) : void
Parameters
$site : Site

An implementation of the \Pipit\Interfaces\Site interface

configurationFileExists()

Checks for the existence of a file with the given filename

protected configurationFileExists(string $configurationFileName) : bool
Parameters
$configurationFileName : string

The name of the file without extension or path

Return values
bool

createDirectory()

Attempts to create a directory with the given name

protected createDirectory(string $directory) : void
Parameters
$directory : string

The name of the directory to create

getConfigurationFromFileName()

Retrieves a config array by its corresponding filename

protected getConfigurationFromFileName(string $configurationFileName) : array<string|int, mixed>
Parameters
$configurationFileName : string

The name of the file without extension or path

Return values
array<string|int, mixed>

checkFile()

private checkFile(string $filePath) : void
Parameters
$filePath : string

Checks for the existence of a full file path

loadConfigurationFile()

Loads and parses a php ini file into an array keyed by ini sections

private loadConfigurationFile(string $configurationFileName) : void
Parameters
$configurationFileName : string

The name of the file without extension or path


        
On this page

Search results