Augmentation vers version 3.3.0
This commit is contained in:
@@ -25,7 +25,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
protected $performDeepMerging = true;
|
||||
protected $ignoreExtraKeys = false;
|
||||
protected $removeExtraKeys = true;
|
||||
protected $children = array();
|
||||
protected $children = [];
|
||||
protected $prototype;
|
||||
protected $atLeastOne = false;
|
||||
protected $allowNewKeys = true;
|
||||
@@ -43,8 +43,8 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
{
|
||||
parent::__construct($name, $parent);
|
||||
|
||||
$this->nullEquivalent = array();
|
||||
$this->trueEquivalent = array();
|
||||
$this->nullEquivalent = [];
|
||||
$this->trueEquivalent = [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,6 +75,62 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
return $this->prototype = $this->getNodeBuilder()->node(null, $type)->setParent($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return VariableNodeDefinition
|
||||
*/
|
||||
public function variablePrototype()
|
||||
{
|
||||
return $this->prototype('variable');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ScalarNodeDefinition
|
||||
*/
|
||||
public function scalarPrototype()
|
||||
{
|
||||
return $this->prototype('scalar');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BooleanNodeDefinition
|
||||
*/
|
||||
public function booleanPrototype()
|
||||
{
|
||||
return $this->prototype('boolean');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return IntegerNodeDefinition
|
||||
*/
|
||||
public function integerPrototype()
|
||||
{
|
||||
return $this->prototype('integer');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FloatNodeDefinition
|
||||
*/
|
||||
public function floatPrototype()
|
||||
{
|
||||
return $this->prototype('float');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ArrayNodeDefinition
|
||||
*/
|
||||
public function arrayPrototype()
|
||||
{
|
||||
return $this->prototype('array');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return EnumNodeDefinition
|
||||
*/
|
||||
public function enumPrototype()
|
||||
{
|
||||
return $this->prototype('enum');
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the default value if the node is not set in the configuration.
|
||||
*
|
||||
@@ -158,15 +214,15 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
* to be the key of the particular item. For example, if "id" is the
|
||||
* "key", then:
|
||||
*
|
||||
* array(
|
||||
* array('id' => 'my_name', 'foo' => 'bar'),
|
||||
* );
|
||||
* [
|
||||
* ['id' => 'my_name', 'foo' => 'bar'],
|
||||
* ];
|
||||
*
|
||||
* becomes
|
||||
*
|
||||
* array(
|
||||
* 'my_name' => array('foo' => 'bar'),
|
||||
* );
|
||||
* [
|
||||
* 'my_name' => ['foo' => 'bar'],
|
||||
* ];
|
||||
*
|
||||
* If you'd like "'id' => 'my_name'" to still be present in the resulting
|
||||
* array, then you can set the second argument of this method to false.
|
||||
@@ -219,9 +275,9 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
{
|
||||
$this
|
||||
->addDefaultsIfNotSet()
|
||||
->treatFalseLike(array('enabled' => false))
|
||||
->treatTrueLike(array('enabled' => true))
|
||||
->treatNullLike(array('enabled' => true))
|
||||
->treatFalseLike(['enabled' => false])
|
||||
->treatTrueLike(['enabled' => true])
|
||||
->treatNullLike(['enabled' => true])
|
||||
->beforeNormalization()
|
||||
->ifArray()
|
||||
->then(function ($v) {
|
||||
@@ -249,9 +305,9 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
{
|
||||
$this
|
||||
->addDefaultsIfNotSet()
|
||||
->treatFalseLike(array('enabled' => false))
|
||||
->treatTrueLike(array('enabled' => true))
|
||||
->treatNullLike(array('enabled' => true))
|
||||
->treatFalseLike(['enabled' => false])
|
||||
->treatTrueLike(['enabled' => true])
|
||||
->treatNullLike(['enabled' => true])
|
||||
->children()
|
||||
->booleanNode('enabled')
|
||||
->defaultTrue()
|
||||
@@ -276,10 +332,10 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
* Allows extra config keys to be specified under an array without
|
||||
* throwing an exception.
|
||||
*
|
||||
* Those config values are simply ignored and removed from the
|
||||
* resulting array. This should be used only in special cases where
|
||||
* you want to send an entire configuration array through a special
|
||||
* tree that processes only part of the array.
|
||||
* Those config values are ignored and removed from the resulting
|
||||
* array. This should be used only in special cases where you want
|
||||
* to send an entire configuration array through a special tree that
|
||||
* processes only part of the array.
|
||||
*
|
||||
* @param bool $remove Whether to remove the extra keys
|
||||
*
|
||||
@@ -356,6 +412,10 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
$node->setKeyAttribute($this->key, $this->removeKeyItem);
|
||||
}
|
||||
|
||||
if (false === $this->allowEmptyValue) {
|
||||
@trigger_error(sprintf('Using %s::cannotBeEmpty() at path "%s" has no effect, consider requiresAtLeastOneElement() instead. In 4.0 both methods will behave the same.', __CLASS__, $node->getPath()), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
if (true === $this->atLeastOne) {
|
||||
$node->setMinNumberOfElements(1);
|
||||
}
|
||||
@@ -381,6 +441,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
$node->addEquivalentValue(false, $this->falseEquivalent);
|
||||
$node->setPerformDeepMerging($this->performDeepMerging);
|
||||
$node->setRequired($this->required);
|
||||
$node->setDeprecated($this->deprecationMessage);
|
||||
$node->setIgnoreExtraKeys($this->ignoreExtraKeys, $this->removeExtraKeys);
|
||||
$node->setNormalizeKeys($this->normalizeKeys);
|
||||
|
||||
@@ -414,6 +475,10 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
throw new InvalidDefinitionException(sprintf('->useAttributeAsKey() is not applicable to concrete nodes at path "%s"', $path));
|
||||
}
|
||||
|
||||
if (false === $this->allowEmptyValue) {
|
||||
@trigger_error(sprintf('->cannotBeEmpty() is not applicable to concrete nodes at path "%s". In 4.0 it will throw an exception.', $path), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
if (true === $this->atLeastOne) {
|
||||
throw new InvalidDefinitionException(sprintf('->requiresAtLeastOneElement() is not applicable to concrete nodes at path "%s"', $path));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user