Manager
Manager
Unified facade for file backends and higher-level file operations.
class Manager implements \Hazaar\File\BackendProperties
defaultConfig
public array $defaultConfig = array (
'enabled' => true,
'auth' => false,
'allow' =>
array (
'read' => false,
0 => NULL,
'cmd' => false,
1 => NULL,
'dir' => true,
2 => NULL,
'filebrowser' => false,
3 => NULL,
),
'userdef' =>
array (
),
'failover' => false,
'log' => false,
)name
Logical source name used by configuration and URL helpers.
public string $namemimeTypes
public array $mimeTypesbackendAliases
private array $backendAliases = array (
'googledrive' => 'GoogleDrive',
'sharepoint' => 'SharePoint',
'webdav' => 'WebDAV',
'dbi' => 'DBI',
0 => NULL,
)defaultBackend
Default backend name used when a manager is created without arguments.
private string $defaultBackend = 'local'defaultBackend_options
private array $defaultBackend_optionsbackend
Active backend implementation instance.
private Backend $backendbackendName
Normalised backend name used to create this manager.
private string $backendNameoptions
private array $optionsfailover
public Manager $failoverinFailover
Indicates the manager is currently performing failover writes.
private bool $inFailoverMethods
__construct
Manager constructor.
public __construct(?string $backend, array $backendOptions, ?string $name): voidParameters
| Parameter | Type | Description |
|---|---|---|
$backend | string | |
$backendOptions | array | |
$name | string |
__destruct
Flushes pending failover writes when the manager is destroyed.
public __destruct(): voidgetAvailableBackends
public getAvailableBackends(false $): voidParameters
| Parameter | Type | Description |
|---|---|---|
$ | false |
select
Loads a Manager class by name as configured in media.json config.
public select(string $name, ?array $options): ManagerParameters
| Parameter | Type | Description |
|---|---|---|
$name | string | The name of the media source to load |
$options | array |
refresh
Refreshes backend state/cache.
public refresh(bool $reset): boolParameters
| Parameter | Type | Description |
|---|---|---|
$reset | bool |
configure
public configure(string $backend, array $options): voidParameters
| Parameter | Type | Description |
|---|---|---|
$backend | string | |
$options | array |
activateFailover
Enables local-disk failover storage for backend write operations.
public activateFailover(): voidfailoverSync
Pushes failover files back to the primary backend and cleans temp copies.
public failoverSync(): boolgetBackend
Returns the active backend implementation.
public getBackend(): BackendgetBackendName
Returns the configured backend name.
public getBackendName(): stringsetOption
Sets a manager runtime option.
public setOption(string $name, mixed $value): voidParameters
| Parameter | Type | Description |
|---|---|---|
$name | string | |
$value | mixed |
getOption
Returns a manager runtime option.
public getOption(string $name): mixedParameters
| Parameter | Type | Description |
|---|---|---|
$name | string |
fixPath
Normalises path input relative to backend root/cwd.
public fixPath(string $path, ?string $file): stringParameters
| Parameter | Type | Description |
|---|---|---|
$path | string | |
$file | string |
authorise
Performs backend authorisation flow.
public authorise(?string $redirectUri): boolParameters
| Parameter | Type | Description |
|---|---|---|
$redirectUri | string |
authorize
Alias to authorise() which is the CORRECT spelling.
public authorize(?string $redirectUri): mixedParameters
| Parameter | Type | Description |
|---|---|---|
$redirectUri | string |
authoriseWithCode
Completes authorisation flow using an auth code.
public authoriseWithCode(string $code, ?string $redirectUri, string $grantType = 'authorization_code'): boolParameters
| Parameter | Type | Description |
|---|---|---|
$code | string | |
$redirectUri | string | |
$grantType | string |
authorised
Returns whether the backend is authorised.
public authorised(): boolauthorized
US-spelling alias for authorised().
public authorized(): boolreset
Resets backend authorisation/session state when supported.
public reset(): boolbuildAuthURL
Builds an external backend authorisation URL.
public buildAuthURL(?string $callbackUrl): ?stringParameters
| Parameter | Type | Description |
|---|---|---|
$callbackUrl | string |
get
Return a file object for a given path.
public get(mixed $path): voidParameters
| Parameter | Type | Description |
|---|---|---|
$path | mixed | The path to a file object |
dir
Return a directory object for a given path.
public dir(string $path = '/'): voidParameters
| Parameter | Type | Description |
|---|---|---|
$path | string | The path to a directory object |
toArray
Return a directory object for a given path.
public toArray(string $path, int $sort = 'SCANDIR_SORT_ASCENDING', bool $allowHidden): voidParameters
| Parameter | Type | Description |
|---|---|---|
$path | string | |
$sort | int | |
$allowHidden | bool |
find
Return a directory object for a given path.
public find(?string $search, string $path = '/', bool $caseInsensitive): voidParameters
| Parameter | Type | Description |
|---|---|---|
$search | string | |
$path | string | |
$caseInsensitive | bool |
exists
Returns true when a path exists on the backend.
public exists(string $path): boolParameters
| Parameter | Type | Description |
|---|---|---|
$path | string |
read
Reads file content from primary backend or failover store.
public read(string $file, int $offset = -1, ?int $maxlen): stringParameters
| Parameter | Type | Description |
|---|---|---|
$file | string | |
$offset | int | |
$maxlen | int |
write
Writes file content to the backend (with optional failover buffering).
public write(string $file, string $data, ?string $contentType, bool $overwrite): ?intParameters
| Parameter | Type | Description |
|---|---|---|
$file | string | |
$data | string | |
$contentType | string | |
$overwrite | bool |
upload
public upload(string $path, array $file, bool $overwrite): boolParameters
| Parameter | Type | Description |
|---|---|---|
$path | string | |
$file | array | |
$overwrite | bool |
store
Stores a local file into this manager's backend.
public store(string $source, string $target): boolParameters
| Parameter | Type | Description |
|---|---|---|
$source | string | |
$target | string |
copy
Copies a file or directory, including cross-backend copy when needed.
public copy(string $src, string $dst, bool $overwrite, ?Manager $srcManager, ?\Closure $callback): boolParameters
| Parameter | Type | Description |
|---|---|---|
$src | string | |
$dst | string | |
$overwrite | bool | |
$srcManager | Manager | |
$callback | \Closure |
move
Moves a file or directory, including cross-backend move when needed.
public move(string $src, string $dst, ?Manager $srcManager): boolParameters
| Parameter | Type | Description |
|---|---|---|
$src | string | |
$dst | string | |
$srcManager | Manager |
mkdir
Creates a directory.
public mkdir(string $path): boolParameters
| Parameter | Type | Description |
|---|---|---|
$path | string |
rmdir
Removes a directory.
public rmdir(string $path, bool $recurse): boolParameters
| Parameter | Type | Description |
|---|---|---|
$path | string | |
$recurse | bool |
unlink
Removes a file or link.
public unlink(string $path): boolParameters
| Parameter | Type | Description |
|---|---|---|
$path | string |
isEmpty
Returns whether a directory contains no entries.
public isEmpty(string $path): boolParameters
| Parameter | Type | Description |
|---|---|---|
$path | string |
filesize
Returns file size in bytes.
public filesize(string $path): intParameters
| Parameter | Type | Description |
|---|---|---|
$path | string |
fsck
Runs backend consistency checks where supported.
public fsck(bool $skipRootReload): boolParameters
| Parameter | Type | Description |
|---|---|---|
$skipRootReload | bool |
thumbnailURL
public thumbnailURL(string $path, int $width = 100, int $height = 100, string $format = 'jpeg', array $params): stringParameters
| Parameter | Type | Description |
|---|---|---|
$path | string | |
$width | int | |
$height | int | |
$format | string | |
$params | array |
link
Creates a link from source to destination when supported.
public link(string $src, string $dst): boolParameters
| Parameter | Type | Description |
|---|---|---|
$src | string | |
$dst | string |
getMeta
Reads metadata for a path.
public getMeta(string $path, ?string $key, string $): voidParameters
| Parameter | Type | Description |
|---|---|---|
$path | string | |
$key | string | |
$ | string |
setMeta
public setMeta(string $path, array $values): boolParameters
| Parameter | Type | Description |
|---|---|---|
$path | string | |
$values | array |
url
Builds an application URL for this media source and path.
public url(?string $path): URLParameters
| Parameter | Type | Description |
|---|---|---|
$path | string |
scandir
public scandir(string $path, ?string $regexFilter, int $sort = 'SCANDIR_SORT_ASCENDING', bool $showHidden, ?string $relativePath, false $): voidParameters
| Parameter | Type | Description |
|---|---|---|
$path | string | |
$regexFilter | string | |
$sort | int | |
$showHidden | bool | |
$relativePath | string | |
$ | false |
touch
Updates file modification/access timestamps.
public touch(string $path): boolParameters
| Parameter | Type | Description |
|---|---|---|
$path | string |
realpath
Returns the canonical backend path when available.
public realpath(string $path): ?stringParameters
| Parameter | Type | Description |
|---|---|---|
$path | string |
isReadable
Returns whether a path is readable.
public isReadable(string $path): boolParameters
| Parameter | Type | Description |
|---|---|---|
$path | string |
isWritable
Returns whether a path is writable.
public isWritable(string $path): boolParameters
| Parameter | Type | Description |
|---|---|---|
$path | string |
isDir
Returns whether a path is a directory.
public isDir(string $path): boolParameters
| Parameter | Type | Description |
|---|---|---|
$path | string |
isLink
Returns whether a path is a symbolic link.
public isLink(string $path): boolParameters
| Parameter | Type | Description |
|---|---|---|
$path | string |
isFile
Returns whether a path is a regular file.
public isFile(string $path): boolParameters
| Parameter | Type | Description |
|---|---|---|
$path | string |
filetype
Returns backend file type string for a path.
public filetype(string $path): stringParameters
| Parameter | Type | Description |
|---|---|---|
$path | string |
filectime
Returns file creation timestamp.
public filectime(string $path): intParameters
| Parameter | Type | Description |
|---|---|---|
$path | string |
filemtime
Returns file modification timestamp.
public filemtime(string $path): intParameters
| Parameter | Type | Description |
|---|---|---|
$path | string |
fileatime
Returns file access timestamp.
public fileatime(string $path): intParameters
| Parameter | Type | Description |
|---|---|---|
$path | string |
fileperms
Returns file permission bits.
public fileperms(string $path): intParameters
| Parameter | Type | Description |
|---|---|---|
$path | string |
chmod
Changes file permissions.
public chmod(string $path, int $mode): boolParameters
| Parameter | Type | Description |
|---|---|---|
$path | string | |
$mode | int |
chown
Changes file owner.
public chown(string $path, string $user): boolParameters
| Parameter | Type | Description |
|---|---|---|
$path | string | |
$user | string |
chgrp
Changes file group.
public chgrp(string $path, string $group): boolParameters
| Parameter | Type | Description |
|---|---|---|
$path | string | |
$group | string |
cwd
Returns current working directory for the backend.
public cwd(): stringmimeContentType
Resolves MIME content type, falling back to extension lookup.
public mimeContentType(string $path): ?stringParameters
| Parameter | Type | Description |
|---|---|---|
$path | string |
md5Checksum
Returns MD5 checksum for a file when supported.
public md5Checksum(string $path): ?stringParameters
| Parameter | Type | Description |
|---|---|---|
$path | string |
previewURL
public previewURL(string $path, array $params): stringParameters
| Parameter | Type | Description |
|---|---|---|
$path | string | |
$params | array |
directURL
Returns a direct access URL for a backend path.
public directURL(string $path): stringParameters
| Parameter | Type | Description |
|---|---|---|
$path | string |
openStream
Opens a backend stream for a path.
public openStream(string $path, string $mode): mixedParameters
| Parameter | Type | Description |
|---|---|---|
$path | string | |
$mode | string |
writeStream
public writeStream(resource $stream, string $bytes, ?int $length): intParameters
| Parameter | Type | Description |
|---|---|---|
$stream | resource | |
$bytes | string | |
$length | int |
readStream
public readStream(resource $stream, int $length): stringParameters
| Parameter | Type | Description |
|---|---|---|
$stream | resource | |
$length | int |
seekStream
public seekStream(mixed $stream, int $offset, int $whence = 'SEEK_SET'): intParameters
| Parameter | Type | Description |
|---|---|---|
$stream | mixed | |
$offset | int | |
$whence | int |
tellStream
public tellStream(mixed $stream): intParameters
| Parameter | Type | Description |
|---|---|---|
$stream | mixed |
eofStream
public eofStream(mixed $stream): boolParameters
| Parameter | Type | Description |
|---|---|---|
$stream | mixed |
truncateStream
public truncateStream(mixed $stream, int $size): boolParameters
| Parameter | Type | Description |
|---|---|---|
$stream | mixed | |
$size | int |
lockStream
public lockStream(mixed $stream, int $operation, ?int $wouldblock): boolParameters
| Parameter | Type | Description |
|---|---|---|
$stream | mixed | |
$operation | int | |
$wouldblock | int |
flushStream
public flushStream(mixed $stream): boolParameters
| Parameter | Type | Description |
|---|---|---|
$stream | mixed |
getsStream
Reads a line from an open backend stream.
public getsStream(mixed $stream, ?int $length): stringParameters
| Parameter | Type | Description |
|---|---|---|
$stream | mixed | |
$length | int |
closeStream
public closeStream(resource $stream): boolParameters
| Parameter | Type | Description |
|---|---|---|
$stream | resource |
lookupContentType
Looks up MIME type by file extension from mime.types support file.
public lookupContentType(string $extension): ?stringParameters
| Parameter | Type | Description |
|---|---|---|
$extension | string |
deepCopy
Recursively copies directory contents between backends.
private deepCopy(string $src, string $dst, Manager $srcManager, ?\Closure $progressCallback): boolParameters
| Parameter | Type | Description |
|---|---|---|
$src | string | |
$dst | string | |
$srcManager | Manager | |
$progressCallback | \Closure |
Generated by Hazaar API Doc Generator on Tue, 21 Apr 2026 04:00:24 +0000