Documentation

YamlUpdater
in package

FinalYes

Grav YAML updater.

NOTE: This class can be initialized during upgrade from an older version of Grav. Make sure it runs there!

Table of Contents

Properties

$comments  : array<string|int, mixed>
$filename  : string
$instance  : array<string|int, self>
$items  : array<string|int, mixed>
$lines  : array<string|int, string>
$updated  : bool

Methods

define()  : void
getComments()  : array<string|int, mixed>
instance()  : self
isHandWritten()  : bool
save()  : bool
undefine()  : void
__construct()  : mixed
canDefine()  : bool
Get value by using dot notation for nested arrays/objects.
findPath()  : array<string|int, int>
Return array of offsets for the parent nodes. Negative value means position, but not found.
get()  : mixed
Get value by using dot notation for nested arrays/objects.
getInlineComment()  : string|null
getLineIndentation()  : int
Returns the current line indentation.
isInlineComment()  : bool
isLineBlank()  : bool
Returns true if the current line is blank.
isLineComment()  : bool
Returns true if the current line is a comment line.
isLineEmpty()  : bool
Returns true if the current line is blank or if it is a comment line.
set()  : void
Set value by using dot notation for nested arrays/objects.
undef()  : void
Unset value by using dot notation for nested arrays/objects.

Properties

$comments

protected array<string|int, mixed> $comments

$instance

protected static array<string|int, self> $instance

Methods

define()

public define(string $variable, mixed $value) : void
Parameters
$variable : string
$value : mixed

getComments()

public getComments() : array<string|int, mixed>
Return values
array<string|int, mixed>

instance()

public static instance(string $filename) : self
Parameters
$filename : string
Return values
self

isHandWritten()

public isHandWritten() : bool
Return values
bool

undefine()

public undefine(string $variable) : void
Parameters
$variable : string

__construct()

private __construct(string $filename) : mixed
Parameters
$filename : string

canDefine()

Get value by using dot notation for nested arrays/objects.

private canDefine(string $name) : bool
Parameters
$name : string

Dot separated path to the requested value.

Return values
bool

findPath()

Return array of offsets for the parent nodes. Negative value means position, but not found.

private findPath(array<string|int, mixed> $lines, array<string|int, mixed> $parts) : array<string|int, int>
Parameters
$lines : array<string|int, mixed>
$parts : array<string|int, mixed>
Return values
array<string|int, int>

get()

Get value by using dot notation for nested arrays/objects.

private get(string $name[, mixed $default = null ]) : mixed
Parameters
$name : string

Dot separated path to the requested value.

$default : mixed = null

Default value (or null).

Return values
mixed

Value.

getInlineComment()

private getInlineComment(string $line) : string|null
Parameters
$line : string
Return values
string|null

getLineIndentation()

Returns the current line indentation.

private getLineIndentation(string $line) : int
Parameters
$line : string
Return values
int

The current line indentation

isInlineComment()

private isInlineComment(string $line) : bool
Parameters
$line : string
Return values
bool

isLineBlank()

Returns true if the current line is blank.

private isLineBlank(string $line) : bool
Parameters
$line : string

Contents of the line

Return values
bool

Returns true if the current line is blank, false otherwise

isLineComment()

Returns true if the current line is a comment line.

private isLineComment(string $line) : bool
Parameters
$line : string

Contents of the line

Return values
bool

Returns true if the current line is a comment line, false otherwise

isLineEmpty()

Returns true if the current line is blank or if it is a comment line.

private isLineEmpty(string $line) : bool
Parameters
$line : string

Contents of the line

Return values
bool

Returns true if the current line is empty or if it is a comment line, false otherwise

set()

Set value by using dot notation for nested arrays/objects.

private set(string $name, mixed $value) : void
Parameters
$name : string

Dot separated path to the requested value.

$value : mixed

New value.

undef()

Unset value by using dot notation for nested arrays/objects.

private undef(string $name) : void
Parameters
$name : string

Dot separated path to the requested value.


        
On this page

Search results