abstract class BaseNode implements NodeInterface

The base node class.

Constants

DEFAULT_PATH_SEPARATOR

Properties

protected $name
protected $parent
protected $normalizationClosures
protected $finalValidationClosures
protected $allowOverwrite
protected $required
protected $deprecationMessage
protected $equivalentValues
protected $attributes
protected $pathSeparator

Methods

__construct(string|null $name, NodeInterface $parent = null, string $pathSeparator = self::DEFAULT_PATH_SEPARATOR)

No description

static void
setPlaceholder(string $placeholder, array $values)

Register possible (dummy) values for a dynamic placeholder value.

static void
setPlaceholderUniquePrefix(string $prefix)

Sets a common prefix for dynamic placeholder values.

static void
resetPlaceholders()

Resets all current placeholders available.

setAttribute($key, $value)

No description

getAttribute($key, $default = null)

No description

hasAttribute($key)

No description

getAttributes()

No description

setAttributes(array $attributes)

No description

removeAttribute($key)

No description

setInfo(string $info)

Sets an info message.

string
getInfo()

Returns info message.

setExample(string|array $example)

Sets the example configuration for this node.

string|array
getExample()

Retrieves the example configuration for this node.

addEquivalentValue(mixed $originalValue, mixed $equivalentValue)

Adds an equivalent value.

setRequired(bool $boolean)

Set this node as required.

setDeprecated(string|null $message)

Sets this node as deprecated.

setAllowOverwrite(bool $allow)

Sets if this node can be overridden.

setNormalizationClosures(array $closures)

Sets the closures used for normalization.

setFinalValidationClosures(array $closures)

Sets the closures used for final validation.

bool
isRequired()

Returns true when the node is required.

bool
isDeprecated()

Checks if this node is deprecated.

string
getDeprecationMessage(string $node, string $path)

Returns the deprecated message.

string
getName()

Returns the name of the node.

string
getPath()

Returns the path of the node.

mixed
merge(mixed $leftSide, mixed $rightSide)

Merges two values together.

mixed
normalize(mixed $value)

Normalizes a value.

The
preNormalize($value)

Normalizes the value before any other normalization is applied.

getParent()

Returns parent node for this node.

mixed
finalize(mixed $value)

Finalizes a value.

validateType(mixed $value)

Validates the type of a Node.

mixed
normalizeValue(mixed $value)

Normalizes the value.

mixed
mergeValues(mixed $leftSide, mixed $rightSide)

Merges two values together.

mixed
finalizeValue(mixed $value)

Finalizes a value.

bool
allowPlaceholders()

Tests if placeholder values are allowed for this node.

bool
isHandlingPlaceholder()

Tests if a placeholder is being handled currently.

array
getValidPlaceholderTypes()

Gets allowed dynamic types for this node.

Details

at line 48
__construct(string|null $name, NodeInterface $parent = null, string $pathSeparator = self::DEFAULT_PATH_SEPARATOR)

Parameters

string|null $name
NodeInterface $parent
string $pathSeparator

Exceptions

InvalidArgumentException if the name contains a period

at line 67
static void setPlaceholder(string $placeholder, array $values)

Register possible (dummy) values for a dynamic placeholder value.

Matching configuration values will be processed with a provided value, one by one. After a provided value is successfully processed the configuration value is returned as is, thus preserving the placeholder.

Parameters

string $placeholder
array $values

Return Value

void

at line 84
static void setPlaceholderUniquePrefix(string $prefix)

Sets a common prefix for dynamic placeholder values.

Matching configuration values will be skipped from being processed and are returned as is, thus preserving the placeholder. An exact match provided by {see setPlaceholder()} might take precedence.

Parameters

string $prefix

Return Value

void

at line 94
static void resetPlaceholders()

Resets all current placeholders available.

Return Value

void

at line 100
setAttribute($key, $value)

Parameters

$key
$value

at line 105
getAttribute($key, $default = null)

Parameters

$key
$default

at line 110
hasAttribute($key)

Parameters

$key

at line 115
getAttributes()

at line 120
setAttributes(array $attributes)

Parameters

array $attributes

at line 125
removeAttribute($key)

Parameters

$key

at line 135
setInfo(string $info)

Sets an info message.

Parameters

string $info

at line 145
string getInfo()

Returns info message.

Return Value

string The info text

at line 155
setExample(string|array $example)

Sets the example configuration for this node.

Parameters

string|array $example

at line 165
string|array getExample()

Retrieves the example configuration for this node.

Return Value

string|array The example

at line 176
addEquivalentValue(mixed $originalValue, mixed $equivalentValue)

Adds an equivalent value.

Parameters

mixed $originalValue
mixed $equivalentValue

at line 186
setRequired(bool $boolean)

Set this node as required.

Parameters

bool $boolean Required node

at line 199
setDeprecated(string|null $message)

Sets this node as deprecated.

You can use %node% and %path% placeholders in your message to display, respectively, the node name and its complete path.

Parameters

string|null $message Deprecated message

at line 209
setAllowOverwrite(bool $allow)

Sets if this node can be overridden.

Parameters

bool $allow

at line 219
setNormalizationClosures(array $closures)

Sets the closures used for normalization.

Parameters

array $closures An array of Closures used for normalization

at line 229
setFinalValidationClosures(array $closures)

Sets the closures used for final validation.

Parameters

array $closures An array of Closures used for final validation

at line 237
bool isRequired()

Returns true when the node is required.

Return Value

bool If the node is required

at line 247
bool isDeprecated()

Checks if this node is deprecated.

Return Value

bool

at line 260
string getDeprecationMessage(string $node, string $path)

Returns the deprecated message.

Parameters

string $node the configuration node name
string $path the path of the node

Return Value

string

at line 268
string getName()

Returns the name of the node.

Return Value

string The name of the node

at line 276
string getPath()

Returns the path of the node.

Return Value

string The node path

at line 288
final mixed merge(mixed $leftSide, mixed $rightSide)

Merges two values together.

Parameters

mixed $leftSide
mixed $rightSide

Return Value

mixed The merged value

Exceptions

ForbiddenOverwriteException if the configuration path cannot be overwritten
InvalidTypeException if the value type is invalid

at line 329
final mixed normalize(mixed $value)

Normalizes a value.

Parameters

mixed $value The value to normalize

Return Value

mixed The normalized value

Exceptions

InvalidTypeException if the value type is invalid

at line 373
protected The preNormalize($value)

Normalizes the value before any other normalization is applied.

Parameters

$value

Return Value

The normalized array value

at line 383
NodeInterface|null getParent()

Returns parent node for this node.

Return Value

NodeInterface|null

at line 391
final mixed finalize(mixed $value)

Finalizes a value.

Parameters

mixed $value The value to finalize

Return Value

mixed The finalized value

Exceptions

InvalidTypeException if the value type is invalid
InvalidConfigurationException if the value is invalid configuration

at line 436
abstract protected validateType(mixed $value)

Validates the type of a Node.

Parameters

mixed $value The value to validate

Exceptions

InvalidTypeException when the value is invalid

at line 445
abstract protected mixed normalizeValue(mixed $value)

Normalizes the value.

Parameters

mixed $value The value to normalize

Return Value

mixed The normalized value

at line 455
abstract protected mixed mergeValues(mixed $leftSide, mixed $rightSide)

Merges two values together.

Parameters

mixed $leftSide
mixed $rightSide

Return Value

mixed The merged value

at line 464
abstract protected mixed finalizeValue(mixed $value)

Finalizes a value.

Parameters

mixed $value The value to finalize

Return Value

mixed The finalized value

at line 469
protected bool allowPlaceholders()

Tests if placeholder values are allowed for this node.

Return Value

bool

at line 477
protected bool isHandlingPlaceholder()

Tests if a placeholder is being handled currently.

Return Value

bool

at line 485
protected array getValidPlaceholderTypes()

Gets allowed dynamic types for this node.

Return Value

array