Merge remote branch 'kriswallsmith/scalar-nodes'
* kriswallsmith/scalar-nodes: removed a lot of special normalization logic in the configuration by using xml values instead of attributes
This commit is contained in:
commit
067bd0009e
@ -70,12 +70,7 @@ class Configuration implements ConfigurationInterface
|
||||
->children()
|
||||
->arrayNode('types')
|
||||
->useAttributeAsKey('name')
|
||||
->prototype('scalar')
|
||||
->beforeNormalization()
|
||||
->ifTrue(function($v) { return is_array($v) && isset($v['class']); })
|
||||
->then(function($v) { return $v['class']; })
|
||||
->end()
|
||||
->end()
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
->end()
|
||||
->fixXmlConfig('connection')
|
||||
@ -167,12 +162,7 @@ class Configuration implements ConfigurationInterface
|
||||
->children()
|
||||
->arrayNode('hydrators')
|
||||
->useAttributeAsKey('name')
|
||||
->prototype('scalar')
|
||||
->beforeNormalization()
|
||||
->ifTrue(function($v) { return is_array($v) && isset($v['class']); })
|
||||
->then(function($v) { return $v['class']; })
|
||||
->end()
|
||||
->end()
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
->end()
|
||||
->fixXmlConfig('mapping')
|
||||
@ -204,30 +194,15 @@ class Configuration implements ConfigurationInterface
|
||||
->children()
|
||||
->arrayNode('string_functions')
|
||||
->useAttributeAsKey('name')
|
||||
->prototype('scalar')
|
||||
->beforeNormalization()
|
||||
->ifTrue(function($v) { return is_array($v) && isset($v['class']); })
|
||||
->then(function($v) { return $v['class']; })
|
||||
->end()
|
||||
->end()
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
->arrayNode('numeric_functions')
|
||||
->useAttributeAsKey('name')
|
||||
->prototype('scalar')
|
||||
->beforeNormalization()
|
||||
->ifTrue(function($v) { return is_array($v) && isset($v['class']); })
|
||||
->then(function($v) { return $v['class']; })
|
||||
->end()
|
||||
->end()
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
->arrayNode('datetime_functions')
|
||||
->useAttributeAsKey('name')
|
||||
->prototype('scalar')
|
||||
->beforeNormalization()
|
||||
->ifTrue(function($v) { return is_array($v) && isset($v['class']); })
|
||||
->then(function($v) { return $v['class']; })
|
||||
->end()
|
||||
->end()
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
|
@ -43,8 +43,11 @@
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="type">
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
<xsd:attribute name="class" type="xsd:string" use="required" />
|
||||
<xsd:simpleContent>
|
||||
<xsd:extension base="xsd:string">
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:extension>
|
||||
</xsd:simpleContent>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="connection">
|
||||
@ -112,7 +115,10 @@
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="dql_function">
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
<xsd:attribute name="class" type="xsd:string" use="required" />
|
||||
<xsd:simpleContent>
|
||||
<xsd:extension base="xsd:string">
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:extension>
|
||||
</xsd:simpleContent>
|
||||
</xsd:complexType>
|
||||
</xsd:schema>
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
<config>
|
||||
<dbal default-connection="default">
|
||||
<type name="test" class="Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestType" />
|
||||
<type name="test">Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestType</type>
|
||||
<connection name="default" />
|
||||
</dbal>
|
||||
</config>
|
||||
|
@ -12,9 +12,9 @@
|
||||
<entity-manager name="default">
|
||||
<mapping name="YamlBundle" />
|
||||
<dql>
|
||||
<string-function name="test_string" class="Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestStringFunction" />
|
||||
<numeric-function name="test_numeric" class="Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestNumericFunction" />
|
||||
<datetime-function name="test_datetime" class="Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestDatetimeFunction" />
|
||||
<string-function name="test_string">Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestStringFunction</string-function>
|
||||
<numeric-function name="test_numeric">Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestNumericFunction</numeric-function>
|
||||
<datetime-function name="test_datetime">Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestDatetimeFunction</datetime-function>
|
||||
</dql>
|
||||
</entity-manager>
|
||||
</orm>
|
||||
|
@ -10,7 +10,7 @@
|
||||
<dbal />
|
||||
<orm default-entity-manager="default">
|
||||
<entity-manager name="default">
|
||||
<hydrator name="test_hydrator" class="Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestHydrator" />
|
||||
<hydrator name="test_hydrator">Symfony\Bundle\DoctrineBundle\Tests\DependencyInjection\TestHydrator</hydrator>
|
||||
<mapping name="YamlBundle" />
|
||||
</entity-manager>
|
||||
</orm>
|
||||
|
@ -195,12 +195,7 @@ class Configuration implements ConfigurationInterface
|
||||
->ifTrue(function($v){ return !is_array($v); })
|
||||
->then(function($v){ return array($v); })
|
||||
->end()
|
||||
->prototype('scalar')
|
||||
->beforeNormalization()
|
||||
->ifTrue(function($v) { return is_array($v) && isset($v['value']); })
|
||||
->then(function($v){ return $v['value']; })
|
||||
->end()
|
||||
->end()
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
->scalarNode('cache')->end()
|
||||
->scalarNode('cache_warmer')->defaultFalse()->end()
|
||||
@ -213,13 +208,8 @@ class Configuration implements ConfigurationInterface
|
||||
->beforeNormalization()
|
||||
->ifTrue(function($v){ return !is_array($v); })
|
||||
->then(function($v){ return array($v); })
|
||||
->end()
|
||||
->prototype('scalar')
|
||||
->beforeNormalization()
|
||||
->ifTrue(function($v) { return is_array($v) && isset($v['id']); })
|
||||
->then(function($v){ return $v['id']; })
|
||||
->end()
|
||||
->end()
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
->end()
|
||||
->fixXmlConfig('loader')
|
||||
@ -237,18 +227,11 @@ class Configuration implements ConfigurationInterface
|
||||
->arrayNode('packages')
|
||||
->useAttributeAsKey('name')
|
||||
->prototype('array')
|
||||
->children()
|
||||
->scalarNode('version')->defaultNull()->end()
|
||||
->end()
|
||||
->fixXmlConfig('base_url')
|
||||
->children()
|
||||
->scalarNode('version')->defaultNull()->end()
|
||||
->arrayNode('base_urls')
|
||||
->prototype('scalar')
|
||||
->beforeNormalization()
|
||||
->ifTrue(function($v) { return is_array($v) && isset($v['value']); })
|
||||
->then(function($v){ return $v['value']; })
|
||||
->end()
|
||||
->end()
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
@ -300,12 +283,7 @@ class Configuration implements ConfigurationInterface
|
||||
->children()
|
||||
->arrayNode('namespaces')
|
||||
->useAttributeAsKey('prefix')
|
||||
->prototype('scalar')
|
||||
->beforeNormalization()
|
||||
->ifTrue(function($v) { return is_array($v) && isset($v['namespace']); })
|
||||
->then(function($v){ return $v['namespace']; })
|
||||
->end()
|
||||
->end()
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
|
@ -94,7 +94,7 @@
|
||||
<xsd:complexType name="templating">
|
||||
<xsd:sequence>
|
||||
<xsd:element name="loader" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
|
||||
<xsd:element name="engine" type="templating_engine" minOccurs="1" maxOccurs="unbounded" />
|
||||
<xsd:element name="engine" type="xsd:string" minOccurs="1" maxOccurs="unbounded" />
|
||||
<xsd:element name="assets-base-url" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
|
||||
<xsd:element name="package" type="package" minOccurs="0" maxOccurs="unbounded" />
|
||||
</xsd:sequence>
|
||||
@ -104,10 +104,6 @@
|
||||
<xsd:attribute name="cache-warmer" type="cache_warmer" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="templating_engine">
|
||||
<xsd:attribute name="id" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="package">
|
||||
<xsd:sequence>
|
||||
<xsd:element name="base-url" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
|
||||
@ -133,7 +129,10 @@
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="validation_namespace">
|
||||
<xsd:attribute name="prefix" type="xsd:string" />
|
||||
<xsd:attribute name="namespace" type="xsd:string" />
|
||||
<xsd:simpleContent>
|
||||
<xsd:extension base="xsd:string">
|
||||
<xsd:attribute name="prefix" type="xsd:string" />
|
||||
</xsd:extension>
|
||||
</xsd:simpleContent>
|
||||
</xsd:complexType>
|
||||
</xsd:schema>
|
||||
|
@ -15,8 +15,8 @@
|
||||
<app:templating assets-version="SomeVersionScheme" cache-warmer="true" cache="/path/to/cache" >
|
||||
<app:loader>loader.foo</app:loader>
|
||||
<app:loader>loader.bar</app:loader>
|
||||
<app:engine id="php" />
|
||||
<app:engine id="twig" />
|
||||
<app:engine>php</app:engine>
|
||||
<app:engine>twig</app:engine>
|
||||
<app:assets-base-url>http://cdn.example.com</app:assets-base-url>
|
||||
<app:package name="images" version="1.0.0">
|
||||
<app:base-url>http://images1.example.com</app:base-url>
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
<app:config>
|
||||
<app:validation enabled="true" annotations="true">
|
||||
<app:namespace prefix="app" namespace="Application\Validator\Constraints\" />
|
||||
<app:namespace prefix="app">Application\Validator\Constraints\</app:namespace>
|
||||
</app:validation>
|
||||
</app:config>
|
||||
</container>
|
||||
|
@ -96,12 +96,7 @@ class Configuration implements ConfigurationInterface
|
||||
$node
|
||||
->canBeUnset()
|
||||
->performNoDeepMerging()
|
||||
->prototype('scalar')
|
||||
->beforeNormalization()
|
||||
->ifTrue(function($v) { return is_array($v) && isset($v['callback']); })
|
||||
->then(function($v){ return $v['callback']; })
|
||||
->end()
|
||||
->end()
|
||||
->prototype('scalar')->end()
|
||||
;
|
||||
|
||||
return $node;
|
||||
|
@ -10,13 +10,13 @@
|
||||
<xsd:complexType name="config">
|
||||
<xsd:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<xsd:element name="handler" type="handler" />
|
||||
<xsd:element name="processor" type="processor" />
|
||||
<xsd:element name="processor" type="xsd:string" />
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="handler">
|
||||
<xsd:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<xsd:element name="processor" type="processor" />
|
||||
<xsd:element name="processor" type="xsd:string" />
|
||||
</xsd:choice>
|
||||
<xsd:attribute name="type" type="xsd:string" use="required" />
|
||||
<xsd:attribute name="priority" type="xsd:integer" />
|
||||
@ -34,10 +34,6 @@
|
||||
<xsd:attribute name="formatter" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="processor">
|
||||
<xsd:attribute name="callback" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:simpleType name="level">
|
||||
<xsd:restriction base="xsd:string">
|
||||
<xsd:enumeration value="error" />
|
||||
|
@ -43,12 +43,7 @@ class Configuration implements ConfigurationInterface
|
||||
->fixXmlConfig('extension')
|
||||
->children()
|
||||
->arrayNode('extensions')
|
||||
->prototype('scalar')
|
||||
->beforeNormalization()
|
||||
->ifTrue(function($v) { return is_array($v) && isset($v['id']); })
|
||||
->then(function($v){ return $v['id']; })
|
||||
->end()
|
||||
->end()
|
||||
->prototype('scalar')->end()
|
||||
->end()
|
||||
->end()
|
||||
;
|
||||
|
@ -11,7 +11,7 @@
|
||||
<xsd:sequence>
|
||||
<xsd:element name="form" type="form" minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="global" type="global" minOccurs="0" maxOccurs="unbounded" />
|
||||
<xsd:element name="extension" type="extension" minOccurs="0" maxOccurs="unbounded" />
|
||||
<xsd:element name="extension" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
|
||||
</xsd:sequence>
|
||||
|
||||
<xsd:attribute name="auto-reload" type="xsd:string" />
|
||||
@ -36,10 +36,6 @@
|
||||
<xsd:attribute name="id" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:complexType name="extension">
|
||||
<xsd:attribute name="id" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
|
||||
<xsd:simpleType name="cache_warmer">
|
||||
<xsd:restriction base="xsd:string">
|
||||
<xsd:enumeration value="false" />
|
||||
|
@ -12,7 +12,7 @@
|
||||
</twig:form>
|
||||
<twig:global key="foo" id="bar" type="service" />
|
||||
<twig:global key="pi">3.14</twig:global>
|
||||
<twig:extension id="twig.extension.debug" />
|
||||
<twig:extension id="twig.extension.text" />
|
||||
<twig:extension>twig.extension.debug</twig:extension>
|
||||
<twig:extension>twig.extension.text</twig:extension>
|
||||
</twig:config>
|
||||
</container>
|
||||
|
@ -194,6 +194,11 @@ class PrototypedArrayNode extends ArrayNode
|
||||
if ($this->removeKeyAttribute) {
|
||||
unset($v[$this->keyAttribute]);
|
||||
}
|
||||
|
||||
// if only "value" is left
|
||||
if (1 == count($v) && isset($v['value'])) {
|
||||
$v = $v['value'];
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists($k, $normalized)) {
|
||||
|
Reference in New Issue
Block a user