\App\CoreModule\ModelsJsonFileManager

Tool for reading and writing JSON files

Summary

Methods
Properties
Constants
__construct()
getDirectory()
delete()
exists()
read()
write()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
fixPermissions()
$directory
$commandManager
N/A

Properties

$directory

$directory : string

Type

normal — Directory with files

$commandManager

$commandManager : \App\CoreModule\Models\CommandManager

Type

normal — Command manager

Methods

__construct()

__construct(string  $directory, \App\CoreModule\Models\CommandManager  $commandManager) : mixed

Constructor

Parameters

string $directory

Directory with files

\App\CoreModule\Models\CommandManager $commandManager

Command managers

Returns

mixed

getDirectory()

getDirectory() : string

Returns the directory with files

Returns

string —

Directory with files

delete()

delete(string  $fileName) : void

Deletes the JSON file

Parameters

string $fileName

File name

Throws

\Nette\IOException

exists()

exists(string  $fileName) : bool

Checks if the JSON file exists

Parameters

string $fileName

File name

Returns

bool —

Is file exists?

read()

read(string  $fileName, bool  $forceArray = true) : array|\stdClass

Reads the JSON file and decode it to array

Parameters

string $fileName

File name (without .json)

bool $forceArray

Force object to array conversion

Throws

\Nette\IOException
\Nette\Utils\JsonException

Returns

array|\stdClass —

JSON data in array

write()

write(string  $name, mixed  $array) : void

Encodes the JSON from array and write into the JSON file

Parameters

string $name

File name (without .json)

mixed $array

JSON data in array

Throws

\Nette\IOException
\Nette\Utils\JsonException

fixPermissions()

fixPermissions(string  $fileName) : void

Fixes the permissions

Parameters

string $fileName

File name