class FileParser

FileParser class.

Constants

SOURCE_SEPARATOR

Properties

protected Model $object
static protected FileSystem $fileCache

Methods

static array
parse(string $content)

Parses a page or layout file content.

static string
render($data)

Renders a page or layout object as file content.

process()

No description

string
compile($path)

Compile a page or layout file content as object.

static FileParser
on($object)

No description

static 
setCache($fileCache)

No description

mixed
source(Page $page, Layout $layout, MainController $controller)

Runs the object's PHP file and returns the corresponding object.

handleCorruptCache($data)

No description

string
extractClassFromFile($path)

Extracts the class name from a cache file

Details

at line 46
static array parse(string $content)

Parses a page or layout file content.

The expected file format is following:

---
Data (frontmatter) section
---
PHP code section
---
Html markup section

If the content has only 2 sections they are considered as Data and Html. If there is only a single section, it is considered as Html.

Parameters

string $content

The file content.

Return Value

array

Returns an array with the following indexes: 'data', 'markup', 'code'. The 'markup' and 'code' elements contain strings. The 'settings' element contains the parsed Data as array. If the content string does not contain a section, the corresponding result element has null value.

at line 93
static string render($data)

Renders a page or layout object as file content.

Parameters

$data

Return Value

string

at line 121
process()

No description

at line 166
protected string compile($path)

Compile a page or layout file content as object.

Parameters

$path

Return Value

string

at line 211
static FileParser on($object)

No description

Parameters

$object

Return Value

FileParser

at line 220
static setCache($fileCache)

No description

Parameters

$fileCache

at line 234
mixed source(Page $page, Layout $layout, MainController $controller)

Runs the object's PHP file and returns the corresponding object.

Parameters

Page $page

The page.

Layout $layout

The layout.

MainController $controller

The controller.

Return Value

mixed

at line 250
protected handleCorruptCache($data)

No description

Parameters

$data

at line 273
protected string extractClassFromFile($path)

Extracts the class name from a cache file

Parameters

$path

Return Value

string