\App\CoreModule\ModelsJsonSchemaManager

Tool for reading and validating JSON schemas

Summary

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

Properties

$directory

$directory : string

Type

normal — Directory with files

$commandManager

$commandManager : \App\CoreModule\Models\CommandManager

Type

normal — Command manager

$schema

$schema : string

Type

normal — JSON schema file name

Methods

__construct()

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

Constructor

Parameters

string $configDir

Directory with JSON schemas

\App\CoreModule\Models\CommandManager $commandManager

Command manager

Returns

mixed

delete()

delete(string  $fileName) : void

Deletes the file

Parameters

string $fileName

File name

Throws

\Nette\IOException

exists()

exists(string  $fileName) : bool

Checks if the file exists

Parameters

string $fileName

File name

Returns

bool —

Is file exists?

read()

read(string  $fileName) : mixed

Reads the file

Parameters

string $fileName

File name

Throws

\Nette\IOException

Returns

mixed —

File content

write()

write(string  $fileName, mixed  $content) : void

Writes into the file

Parameters

string $fileName

File name

mixed $content

File content

Throws

\Nette\IOException

getDirectory()

getDirectory() : string

Returns the directory with files

Returns

string —

Directory with files

setSchema()

setSchema(string  $fileName) : void

Sets the JSON schema file name

Parameters

string $fileName

JSON schema file name

Throws

\App\CoreModule\Exceptions\NonExistingJsonSchemaException

validate()

validate(mixed  $json, bool  $tryFix = false) : bool

Validates JSON

Parameters

mixed $json

JSON to validate

bool $tryFix

Try fix JSON?

Throws

\App\CoreModule\Exceptions\InvalidJsonException
\Nette\Utils\JsonException

Returns

bool —

Is the JSON valid?

fixPermissions()

fixPermissions(string  $fileName) : void

Fixes the permissions

Parameters

string $fileName

File name