}
/**
- * Sets a custom children builder.
- *
- * @param NodeBuilder $builder A custom NodeBuilder
+ * {@inheritdoc}
*/
public function setBuilder(NodeBuilder $builder)
{
}
/**
- * Returns a builder to add children nodes.
- *
- * @return NodeBuilder
+ * {@inheritdoc}
*/
public function children()
{
/**
* Sets a prototype for child nodes.
*
- * @param string $type the type of node
+ * @param string $type The type of node
*
* @return NodeDefinition
*/
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.
*
/**
* Adds children with a default value when none are defined.
*
- * @param int|string|array|null $children The number of children|The child name|The children names to be added
- *
* This method is applicable to prototype nodes only.
*
+ * @param int|string|array|null $children The number of children|The child name|The children names to be added
+ *
* @return $this
*/
public function addDefaultChildrenIfNoneSet($children = null)
}
/**
- * Appends a node definition.
- *
- * $node = new ArrayNodeDefinition()
- * ->children()
- * ->scalarNode('foo')->end()
- * ->scalarNode('baz')->end()
- * ->end()
- * ->append($this->getBarNodeDefinition())
- * ;
- *
- * @param NodeDefinition $node A NodeDefinition instance
- *
- * @return $this
+ * {@inheritdoc}
*/
public function append(NodeDefinition $node)
{
$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);
}
$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);
/**
* Validate the configuration of a concrete node.
*
- * @param ArrayNode $node The related node
- *
* @throws InvalidDefinitionException
*/
protected function validateConcreteNode(ArrayNode $node)
);
}
+ 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)
/**
* Validate the configuration of a prototype node.
*
- * @param PrototypedArrayNode $node The related node
- *
* @throws InvalidDefinitionException
*/
protected function validatePrototypeNode(PrototypedArrayNode $node)