This PR was squashed before being merged into the 3.3-dev branch (closes #20923).
Discussion
----------
#20921 [Config] Provide shorthand methods for ArrayNodeDefinition::pr…
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #20921
| License | MIT
Commits
-------
22b8490
#20921 [Config] Provide shorthand methods for ArrayNodeDefinition::pr…
This commit is contained in:
commit
d221a4e1eb
@ -79,6 +79,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.
|
||||
*
|
||||
|
@ -227,6 +227,48 @@ class ArrayNodeDefinitionTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertFalse($this->getField($node, 'normalizeKeys'));
|
||||
}
|
||||
|
||||
public function testPrototypeVariable()
|
||||
{
|
||||
$node = new ArrayNodeDefinition('root');
|
||||
$this->assertEquals($node->prototype('variable'), $node->variablePrototype());
|
||||
}
|
||||
|
||||
public function testPrototypeScalar()
|
||||
{
|
||||
$node = new ArrayNodeDefinition('root');
|
||||
$this->assertEquals($node->prototype('scalar'), $node->scalarPrototype());
|
||||
}
|
||||
|
||||
public function testPrototypeBoolean()
|
||||
{
|
||||
$node = new ArrayNodeDefinition('root');
|
||||
$this->assertEquals($node->prototype('boolean'), $node->booleanPrototype());
|
||||
}
|
||||
|
||||
public function testPrototypeInteger()
|
||||
{
|
||||
$node = new ArrayNodeDefinition('root');
|
||||
$this->assertEquals($node->prototype('integer'), $node->integerPrototype());
|
||||
}
|
||||
|
||||
public function testPrototypeFloat()
|
||||
{
|
||||
$node = new ArrayNodeDefinition('root');
|
||||
$this->assertEquals($node->prototype('float'), $node->floatPrototype());
|
||||
}
|
||||
|
||||
public function testPrototypeArray()
|
||||
{
|
||||
$node = new ArrayNodeDefinition('root');
|
||||
$this->assertEquals($node->prototype('array'), $node->arrayPrototype());
|
||||
}
|
||||
|
||||
public function testPrototypeEnum()
|
||||
{
|
||||
$node = new ArrayNodeDefinition('root');
|
||||
$this->assertEquals($node->prototype('enum'), $node->enumPrototype());
|
||||
}
|
||||
|
||||
public function getEnableableNodeFixtures()
|
||||
{
|
||||
return array(
|
||||
|
Reference in New Issue
Block a user