PrivilegedFileManager
in package
implements
IFileManager
Privileged file manager
Table of Contents
Interfaces
- IFileManager
- File manager interface
Properties
- $commandExecutor : CommandExecutor
- $directory : string
Methods
- __construct() : mixed
- Constructor
- chmod() : void
- Changes the permissions of a file or directory
- chown() : void
- Changes the owner of a file or directory
- copy() : void
- Copies file to a destination
- createDirectory() : void
- Creates a directory
- createSymLink() : void
- Creates the symbolic link
- delete() : void
- Deletes the file
- exists() : bool
- Checks if the file exists
- getBasePath() : string
- Returns Base directory path
- isSymLink() : bool
- Checks if the file is symbolic link
- listDirectories() : array<string|int, string>
- Returns list of subdirectories in directory
- listFiles() : array<int, string>
- Returns list of files in directory
- read() : string
- Reads the file
- readIni() : array<string, mixed>
- Reads an INI file and decodes contents to array
- readJson() : mixed
- Reads a JSON file and decode contents to array
- readNeon() : mixed
- Reads a NEON file and decodes contents to array
- write() : void
- Writes into the file
- writeIni() : void
- Encodes content from array into INI and writes to file
- writeJson() : void
- Encodes content from array into JSON and writes to file
- writeNeon() : void
- Encodes content from array into NEON and writes to file
- buildPath() : string
- Returns path to subdirectory or file, if the path contains spaces, returned string is surrounded in quotation marks
Properties
$commandExecutor read-only
private
CommandExecutor
$commandExecutor
$directory read-only
private
string
$directory
Directory path
Methods
__construct()
Constructor
public
__construct(string $directory, CommandExecutor $commandExecutor) : mixed
Parameters
- $directory : string
-
Directory path
- $commandExecutor : CommandExecutor
-
Command manager
chmod()
Changes the permissions of a file or directory
public
chmod(string|null $path, int $mode[, bool $recursive = false ]) : void
Parameters
- $path : string|null
-
Path to the file or directory
- $mode : int
-
File mode
- $recursive : bool = false
-
Indicates whether the mode should be changed recursively
chown()
Changes the owner of a file or directory
public
chown(string|null $path, string $user[, string|null $group = null ][, bool $recursive = false ]) : void
Parameters
- $path : string|null
-
Path to the file or directory
- $user : string
-
User name
- $group : string|null = null
-
Group name
- $recursive : bool = false
-
Indicates whether the owner should be changed recursively
copy()
Copies file to a destination
public
copy(string $destination, string $fileName) : void
Parameters
- $destination : string
-
Destination path
- $fileName : string
-
Source file path
createDirectory()
Creates a directory
public
createDirectory(string $directory) : void
Parameters
- $directory : string
-
Relative path to subdirectory
createSymLink()
Creates the symbolic link
public
createSymLink(string $target, string $link) : void
Parameters
- $target : string
-
Target of the symbolic link
- $link : string
-
Symbolic link name
delete()
Deletes the file
public
delete(string $fileName) : void
Parameters
- $fileName : string
-
File name
exists()
Checks if the file exists
public
exists(string $fileName) : bool
Parameters
- $fileName : string
-
File name
Return values
bool —Is file exists?
getBasePath()
Returns Base directory path
public
getBasePath() : string
Return values
string —Base directory path
isSymLink()
Checks if the file is symbolic link
public
isSymLink(string $fileName) : bool
Parameters
- $fileName : string
-
File name
Return values
bool —Is symbolic link?
listDirectories()
Returns list of subdirectories in directory
public
listDirectories([string|null $subdirectory = null ]) : array<string|int, string>
Parameters
- $subdirectory : string|null = null
-
Relative path to subdirectory
Return values
array<string|int, string> —List of directories
listFiles()
Returns list of files in directory
public
listFiles([string|null $subdirectory = null ][, bool $includeSymlinks = false ]) : array<int, string>
Parameters
- $subdirectory : string|null = null
-
Relative path to subdirectory
- $includeSymlinks : bool = false
-
Include symlinks in list
Return values
array<int, string> —List of files
read()
Reads the file
public
read(string $fileName) : string
Parameters
- $fileName : string
-
File name
Return values
string —File content
readIni()
Reads an INI file and decodes contents to array
public
readIni(string $fileName) : array<string, mixed>
Parameters
- $fileName : string
-
File name
Return values
array<string, mixed> —Decoded INI file
readJson()
Reads a JSON file and decode contents to array
public
readJson(string $fileName[, bool $forceArray = true ]) : mixed
Parameters
- $fileName : string
-
File name
- $forceArray : bool = true
-
Force object to array conversion
Return values
mixed —Decoded JSON data
readNeon()
Reads a NEON file and decodes contents to array
public
readNeon(string $fileName) : mixed
Parameters
- $fileName : string
-
File name
Return values
mixed —Decoded NEON file
write()
Writes into the file
public
write(string $fileName, mixed $content) : void
Parameters
- $fileName : string
-
File name
- $content : mixed
-
File content
writeIni()
Encodes content from array into INI and writes to file
public
writeIni(string $fileName, array<string|int, mixed> $content) : void
Parameters
- $fileName : string
-
File name
- $content : array<string|int, mixed>
-
Array to encode
writeJson()
Encodes content from array into JSON and writes to file
public
writeJson(string $fileName, mixed $content) : void
Parameters
- $fileName : string
-
File name
- $content : mixed
-
JSON data to encode
writeNeon()
Encodes content from array into NEON and writes to file
public
writeNeon(string $fileName, mixed $content) : void
Parameters
- $fileName : string
-
File name
- $content : mixed
-
NEON data to encode
buildPath()
Returns path to subdirectory or file, if the path contains spaces, returned string is surrounded in quotation marks
private
buildPath(string|null $name) : string
Parameters
- $name : string|null
-
Name of subdirectory or file
Return values
string —Path to subdirectory or file