W3cubDocs

/Symfony 4.1

ScalarNode

class ScalarNode extends VariableNode

This node represents a scalar value in the config tree.

The following values are considered scalars: * booleans * strings * null * integers * floats

Constants

DEFAULT_PATH_SEPARATOR

Properties

protected $name from BaseNode
protected $parent from BaseNode
protected $normalizationClosures from BaseNode
protected $finalValidationClosures from BaseNode
protected $allowOverwrite from BaseNode
protected $required from BaseNode
protected $deprecationMessage from BaseNode
protected $equivalentValues from BaseNode
protected $attributes from BaseNode
protected $pathSeparator from BaseNode
protected $defaultValueSet from VariableNode
protected $defaultValue from VariableNode
protected $allowEmptyValue from VariableNode

Methods

__construct(string|null $name, NodeInterface $parent = null, string $pathSeparator = self::DEFAULT_PATH_SEPARATOR) from BaseNode
static void setPlaceholder(string $placeholder, array $values)

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

from BaseNode
static void setPlaceholderUniquePrefix(string $prefix)

Sets a common prefix for dynamic placeholder values.

from BaseNode
static void resetPlaceholders()

Resets all current placeholders available.

from BaseNode
setAttribute($key, $value) from BaseNode
getAttribute($key, $default = null) from BaseNode
hasAttribute($key) from BaseNode
getAttributes() from BaseNode
setAttributes(array $attributes) from BaseNode
removeAttribute($key) from BaseNode
setInfo(string $info)

Sets an info message.

from BaseNode
string getInfo()

Returns info message.

from BaseNode
setExample(string|array $example)

Sets the example configuration for this node.

from BaseNode
string|array getExample()

Retrieves the example configuration for this node.

from BaseNode
addEquivalentValue(mixed $originalValue, mixed $equivalentValue)

Adds an equivalent value.

from BaseNode
setRequired(bool $boolean)

Set this node as required.

from BaseNode
setDeprecated(string|null $message)

Sets this node as deprecated.

from BaseNode
setAllowOverwrite(bool $allow)

Sets if this node can be overridden.

from BaseNode
setNormalizationClosures(array $closures)

Sets the closures used for normalization.

from BaseNode
setFinalValidationClosures(array $closures)

Sets the closures used for final validation.

from BaseNode
bool isRequired()

Returns true when the node is required.

from BaseNode
bool isDeprecated()

Checks if this node is deprecated.

from BaseNode
string getDeprecationMessage(string $node, string $path)

Returns the deprecated message.

from BaseNode
string getName()

Returns the name of the node.

from BaseNode
string getPath()

Returns the path of the node.

from BaseNode
mixed merge(mixed $leftSide, mixed $rightSide)

Merges two values together.

from BaseNode
mixed normalize(mixed $value)

Normalizes a value.

from BaseNode
$value preNormalize($value)

Normalizes the value before any other normalization is applied.

from BaseNode
NodeInterface|null getParent()

Returns parent node for this node.

from BaseNode
mixed finalize(mixed $value)

Finalizes a value.

from BaseNode
validateType(mixed $value)

Validates the type of a Node.

mixed normalizeValue(mixed $value)

Normalizes the value.

from VariableNode
mixed mergeValues(mixed $leftSide, mixed $rightSide)

Merges two values together.

from VariableNode
mixed finalizeValue(mixed $value)

Finalizes a value.

from VariableNode
bool allowPlaceholders()

Tests if placeholder values are allowed for this node.

from BaseNode
bool isHandlingPlaceholder()

Tests if a placeholder is being handled currently.

from BaseNode
array getValidPlaceholderTypes()

Gets allowed dynamic types for this node.

setDefaultValue($value) from VariableNode
bool hasDefaultValue()

Returns true when the node has a default value.

from VariableNode
mixed getDefaultValue()

Returns the default value of the node.

from VariableNode
setAllowEmptyValue(bool $boolean)

Sets if this node is allowed to have an empty value.

from VariableNode
setName(string $name)

Sets the name of the node.

from VariableNode
bool isValueEmpty(mixed $value)

Evaluates if the given value is to be treated as empty.

Details

__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

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

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

static void resetPlaceholders()

Resets all current placeholders available.

Return Value

void

setAttribute($key, $value)

Parameters

$key
$value

getAttribute($key, $default = null)

Parameters

$key
$default

hasAttribute($key)

Parameters

$key

getAttributes()

setAttributes(array $attributes)

Parameters

array $attributes

removeAttribute($key)

Parameters

$key

setInfo(string $info)

Sets an info message.

Parameters

string $info

string getInfo()

Returns info message.

Return Value

string The info text

setExample(string|array $example)

Sets the example configuration for this node.

Parameters

string|array $example

string|array getExample()

Retrieves the example configuration for this node.

Return Value

string|array The example

addEquivalentValue(mixed $originalValue, mixed $equivalentValue)

Adds an equivalent value.

Parameters

mixed $originalValue
mixed $equivalentValue

setRequired(bool $boolean)

Set this node as required.

Parameters

bool $boolean Required node

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

setAllowOverwrite(bool $allow)

Sets if this node can be overridden.

Parameters

bool $allow

setNormalizationClosures(array $closures)

Sets the closures used for normalization.

Parameters

array $closures An array of Closures used for normalization

setFinalValidationClosures(array $closures)

Sets the closures used for final validation.

Parameters

array $closures An array of Closures used for final validation

bool isRequired()

Returns true when the node is required.

Return Value

bool If the node is required

bool isDeprecated()

Checks if this node is deprecated.

Return Value

bool

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

string getName()

Returns the name of the node.

Return Value

string The name of the node

string getPath()

Returns the path of the node.

Return Value

string The node path

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

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

protected $value preNormalize($value)

Normalizes the value before any other normalization is applied.

Parameters

$value

Return Value

$value The normalized array value

NodeInterface|null getParent()

Returns parent node for this node.

Return Value

NodeInterface|null

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

protected validateType(mixed $value)

Validates the type of a Node.

Parameters

mixed $value The value to validate

Exceptions

InvalidTypeException when the value is invalid

protected mixed normalizeValue(mixed $value)

Normalizes the value.

Parameters

mixed $value The value to normalize

Return Value

mixed The normalized value

protected mixed mergeValues(mixed $leftSide, mixed $rightSide)

Merges two values together.

Parameters

mixed $leftSide
mixed $rightSide

Return Value

mixed The merged value

protected mixed finalizeValue(mixed $value)

Finalizes a value.

Parameters

mixed $value The value to finalize

Return Value

mixed The finalized value

protected bool allowPlaceholders()

Tests if placeholder values are allowed for this node.

Return Value

bool

protected bool isHandlingPlaceholder()

Tests if a placeholder is being handled currently.

Return Value

bool

protected array getValidPlaceholderTypes()

Gets allowed dynamic types for this node.

Return Value

array

setDefaultValue($value)

Parameters

$value

bool hasDefaultValue()

Returns true when the node has a default value.

Return Value

bool If the node has a default value

mixed getDefaultValue()

Returns the default value of the node.

Return Value

mixed The default value

Exceptions

RuntimeException if the node has no default value

setAllowEmptyValue(bool $boolean)

Sets if this node is allowed to have an empty value.

Parameters

bool $boolean True if this entity will accept empty values

setName(string $name)

Sets the name of the node.

Parameters

string $name The name of the node

protected bool isValueEmpty(mixed $value)

Evaluates if the given value is to be treated as empty.

By default, PHP's empty() function is used to test for emptiness. This method may be overridden by subtypes to better match their understanding of empty data.

Parameters

mixed $value

Return Value

bool

© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/Config/Definition/ScalarNode.html