diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index bcbf7d1da780..6ca61d521dd6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -205,7 +205,7 @@ private function addValidationSection(NodeBuilder $rootNode) ->treatTrueLike(array()) ->fixXmlConfig('namespace') ->arrayNode('namespaces') - ->containsNameValuePairsWithKeyAttribute('prefix') + ->useAttributeAsKey('prefix') ->prototype('scalar') ->beforeNormalization() ->ifTrue(function($v) { return is_array($v) && isset($v['namespace']); }) diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Configuration.php index 2bb11266c290..35c9e3afec50 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Configuration.php @@ -67,7 +67,7 @@ protected function addRoleHierarchySection($rootNode) $rootNode ->fixXmlConfig('role', 'role_hierarchy') ->arrayNode('role_hierarchy') - ->containsNameValuePairsWithKeyAttribute('id') + ->useAttributeAsKey('id') ->prototype('array') ->performNoDeepMerging() ->beforeNormalization()->ifString()->then(function($v) { return array('value' => $v); })->end() @@ -103,7 +103,7 @@ protected function addAccessControlSection($rootNode) ->end() ->fixXmlConfig('attribute') ->arrayNode('attributes') - ->containsNameValuePairsWithKeyAttribute('key') + ->useAttributeAsKey('key') ->prototype('scalar') ->beforeNormalization() ->ifTrue(function($v) { return is_array($v) && isset($v['pattern']); }) @@ -122,6 +122,8 @@ protected function addFirewallsSection($rootNode, array $factories) $rootNode ->fixXmlConfig('firewall') ->arrayNode('firewalls') + ->isRequired() + ->requiresAtLeastOneElement() ->disallowNewKeysInSubsequentConfigs() ->useAttributeAsKey('name') ->prototype('array') @@ -183,6 +185,7 @@ protected function addProvidersSection($rootNode) ->fixXmlConfig('provider') ->arrayNode('providers') ->disallowNewKeysInSubsequentConfigs() + ->isRequired() ->requiresAtLeastOneElement() ->useAttributeAsKey('name') ->prototype('array') @@ -220,10 +223,13 @@ protected function addEncodersSection($rootNode) $rootNode ->fixXmlConfig('encoder') ->arrayNode('encoders') + ->requiresAtLeastOneElement() ->useAttributeAsKey('class') ->prototype('array') + ->canBeUnset() + ->performNoDeepMerging() ->beforeNormalization()->ifString()->then(function($v) { return array('algorithm' => $v); })->end() - ->scalarNode('algorithm')->isRequired()->cannotBeEmpty()->end() + ->scalarNode('algorithm')->cannotBeEmpty()->end() ->booleanNode('ignore_case')->end() ->booleanNode('encode_as_base64')->end() ->scalarNode('iterations')->end() diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php index 561bf557470c..0a6a0fa5cd32 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php @@ -470,7 +470,7 @@ protected function createUserDaoProvider($name, $provider, ContainerBuilder $con $definition = $container->register($name, '%security.user.provider.in_memory.class%'); $definition->setPublic(false); foreach ($provider['users'] as $username => $user) { - $userId = $name.'_'.md5(json_encode(array($username, $user['password'], $user['roles']))); + $userId = $name.'_'.$username; $container ->register($userId, 'Symfony\Component\Security\Core\User\User') @@ -486,7 +486,7 @@ protected function createUserDaoProvider($name, $provider, ContainerBuilder $con protected function getUserProviderId($name) { - return 'security.authentication.provider.'.$name; + return 'security.user.provider.'.$name; } protected function createExceptionListener($container, $config, $id, $defaultEntryPoint) diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/access.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/access.php deleted file mode 100644 index 9fee76772063..000000000000 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/access.php +++ /dev/null @@ -1,8 +0,0 @@ -loadFromExtension('security', 'config', array( - 'access_control' => array( - array('path' => '/blog/524', 'role' => 'ROLE_USER', 'requires_channel' => 'https'), - array('path' => '/blog/.*', 'attributes' => array('_controller' => '.*\\BlogBundle\\.*'), 'role' => 'IS_AUTHENTICATED_ANONYMOUSLY'), - ), -)); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/container1.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/container1.php new file mode 100644 index 000000000000..e5b1572eb180 --- /dev/null +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/container1.php @@ -0,0 +1,52 @@ +loadFromExtension('security', 'config', array( + 'providers' => array( + 'default' => array( + 'users' => array( + 'foo' => array('password' => 'foo', 'roles' => 'ROLE_USER'), + ), + ), + 'digest' => array( + 'users' => array( + 'foo' => array('password' => 'foo', 'roles' => 'ROLE_USER, ROLE_ADMIN'), + ), + ), + 'basic' => array( + 'users' => array( + 'foo' => array('password' => '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33', 'roles' => 'ROLE_SUPER_ADMIN'), + 'bar' => array('password' => '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33', 'roles' => array('ROLE_USER', 'ROLE_ADMIN')), + ), + ), + 'doctrine' => array( + 'entity' => array('class' => 'SecurityBundle:User', 'property' => 'username') + ), + 'service' => array( + 'id' => 'user.manager', + ), + ), + + 'firewalls' => array( + 'simple' => array('pattern' => '/login', 'security' => false), + 'secure' => array('stateless' => true, + 'http_basic' => true, + 'http_digest' => true, + 'form_login' => true, + 'anonymous' => true, + 'switch_user' => true, + 'x509' => true, + 'logout' => true, + ), + ), + + 'access_control' => array( + array('path' => '/blog/524', 'role' => 'ROLE_USER', 'requires_channel' => 'https'), + array('path' => '/blog/.*', 'attributes' => array('_controller' => '.*\\BlogBundle\\.*'), 'role' => 'IS_AUTHENTICATED_ANONYMOUSLY'), + ), + + 'role_hierarchy' => array( + 'ROLE_ADMIN' => 'ROLE_USER', + 'ROLE_SUPER_ADMIN' => array('ROLE_USER', 'ROLE_ADMIN', 'ROLE_ALLOWED_TO_SWITCH'), + 'ROLE_REMOTE' => 'ROLE_USER,ROLE_ADMIN', + ), +)); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/firewall.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/firewall.php deleted file mode 100644 index 56240fcdd21c..000000000000 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/firewall.php +++ /dev/null @@ -1,24 +0,0 @@ -loadFromExtension('security', 'config', array( - 'providers' => array( - 'basic' => array( - 'users' => array( - 'foo' => array('password' => 'foo', 'roles' => 'ROLE_USER'), - ), - ), - ), - - 'firewalls' => array( - 'simple' => array('pattern' => '/login', 'security' => false), - 'secure' => array('stateless' => true, - 'http_basic' => true, - 'http_digest' => true, - 'form_login' => true, - 'anonymous' => true, - 'switch_user' => true, - 'x509' => true, - 'logout' => true, - ), - ) -)); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/hierarchy.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/hierarchy.php deleted file mode 100644 index 49127bc0f951..000000000000 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/hierarchy.php +++ /dev/null @@ -1,9 +0,0 @@ -loadFromExtension('security', 'config', array( - 'role_hierarchy' => array( - 'ROLE_ADMIN' => 'ROLE_USER', - 'ROLE_SUPER_ADMIN' => array('ROLE_USER', 'ROLE_ADMIN', 'ROLE_ALLOWED_TO_SWITCH'), - 'ROLE_REMOTE' => 'ROLE_USER,ROLE_ADMIN', - ) -)); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/merge.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/merge.php index 988640fb284d..e061b541f49b 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/merge.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/merge.php @@ -3,12 +3,17 @@ $this->load('merge_import.php', $container); $container->loadFromExtension('security', 'config', array( + 'providers' => array( + 'default' => array('id' => 'foo'), + ), + 'firewalls' => array( 'main' => array( 'form_login' => false, 'http_basic' => null, ), ), + 'role_hierarchy' => array( 'FOO' => array('MOO'), ) diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/provider.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/provider.php deleted file mode 100644 index 83f4f192d655..000000000000 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/provider.php +++ /dev/null @@ -1,24 +0,0 @@ -loadFromExtension('security', 'config', array( - 'providers' => array( - 'digest' => array( - 'users' => array( - 'foo' => array('password' => 'foo', 'roles' => 'ROLE_USER, ROLE_ADMIN'), - ), - ), - 'basic' => array( - 'password_encoder' => 'sha1', - 'users' => array( - 'foo' => array('password' => '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33', 'roles' => 'ROLE_SUPER_ADMIN'), - 'bar' => array('password' => '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33', 'roles' => array('ROLE_USER', 'ROLE_ADMIN')), - ), - ), - 'doctrine' => array( - 'entity' => array('class' => 'SecurityBundle:User', 'property' => 'username') - ), - 'service' => array( - 'id' => 'user.manager', - ), - ) -)); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/access.xml b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/access.xml deleted file mode 100644 index 2ca9f5b9d0c7..000000000000 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/access.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/provider.xml b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/container1.xml similarity index 51% rename from src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/provider.xml rename to src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/container1.xml index e4cbf6d5983f..ccf38ec8612d 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/provider.xml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/container1.xml @@ -1,4 +1,4 @@ - + + + + + - @@ -21,5 +24,26 @@ + + + + + + + + + + + + + + ROLE_USER + ROLE_USER,ROLE_ADMIN,ROLE_ALLOWED_TO_SWITCH + ROLE_USER,ROLE_ADMIN + + + + + diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/firewall.xml b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/firewall.xml deleted file mode 100644 index b3e7987382d1..000000000000 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/firewall.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/hierarchy.xml b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/hierarchy.xml deleted file mode 100644 index 4c8985a79157..000000000000 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/hierarchy.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - ROLE_USER - ROLE_USER,ROLE_ADMIN,ROLE_ALLOWED_TO_SWITCH - ROLE_USER,ROLE_ADMIN - - diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/merge.xml b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/merge.xml index 36f7b4de7208..94087dcdc4c5 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/merge.xml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/merge.xml @@ -10,6 +10,8 @@ + + diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/access.yml b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/access.yml deleted file mode 100644 index 6f531b0cc9f0..000000000000 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/access.yml +++ /dev/null @@ -1,7 +0,0 @@ -security.config: - access_control: - - { path: /blog/524, role: ROLE_USER, requires_channel: https } - - - path: /blog/.* - attributes: { _controller: .*\\BlogBundle\\.* } - role: IS_AUTHENTICATED_ANONYMOUSLY diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/container1.yml b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/container1.yml new file mode 100644 index 000000000000..24165ddcfd17 --- /dev/null +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/container1.yml @@ -0,0 +1,41 @@ +security.config: + providers: + default: + users: + foo: { password: foo, roles: ROLE_USER } + digest: + users: + foo: { password: foo, roles: 'ROLE_USER, ROLE_ADMIN' } + basic: + password_encoder: sha1 + users: + foo: { password: 0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33, roles: ROLE_SUPER_ADMIN } + bar: { password: 0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33, roles: [ROLE_USER, ROLE_ADMIN] } + doctrine: + entity: { class: SecurityBundle:User, property: username } + service: + id: user.manager + + firewalls: + simple: { pattern: /login, security: false } + secure: + stateless: true + http_basic: true + http_digest: true + form_login: true + anonymous: true + switch_user: true + x509: true + logout: true + + role_hierarchy: + ROLE_ADMIN: ROLE_USER + ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH] + ROLE_REMOTE: ROLE_USER,ROLE_ADMIN + + access_control: + - { path: /blog/524, role: ROLE_USER, requires_channel: https } + - + path: /blog/.* + attributes: { _controller: .*\\BlogBundle\\.* } + role: IS_AUTHENTICATED_ANONYMOUSLY diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/firewall.yml b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/firewall.yml deleted file mode 100644 index 578485574e62..000000000000 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/firewall.yml +++ /dev/null @@ -1,17 +0,0 @@ -security.config: - providers: - basic: - users: - foo: { password: foo, roles: ROLE_USER } - - firewalls: - simple: { pattern: /login, security: false } - secure: - stateless: true - http_basic: true - http_digest: true - form_login: true - anonymous: true - switch_user: true - x509: true - logout: true diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/hierarchy.yml b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/hierarchy.yml deleted file mode 100644 index 60cb87efb591..000000000000 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/hierarchy.yml +++ /dev/null @@ -1,5 +0,0 @@ -security.config: - role_hierarchy: - ROLE_ADMIN: ROLE_USER - ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH] - ROLE_REMOTE: ROLE_USER,ROLE_ADMIN diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/merge.yml b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/merge.yml index a42fc99fab00..cd6b673497bb 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/merge.yml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/merge.yml @@ -2,10 +2,13 @@ imports: - { resource: merge_import.yml } security.config: + providers: + default: { id: foo } + firewalls: main: form_login: false http_basic: ~ - + role_hierarchy: FOO: [MOO] \ No newline at end of file diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/provider.yml b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/provider.yml deleted file mode 100644 index 16a975f37ca1..000000000000 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/provider.yml +++ /dev/null @@ -1,17 +0,0 @@ -security.config: - providers: - digest: - users: - foo: { password: foo, roles: 'ROLE_USER, ROLE_ADMIN' } - - basic: - password_encoder: sha1 - users: - foo: { password: 0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33, roles: ROLE_SUPER_ADMIN } - bar: { password: 0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33, roles: [ROLE_USER, ROLE_ADMIN] } - - doctrine: - entity: { class: SecurityBundle:User, property: username } - - service: - id: user.manager diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php index 73df0096914e..5c6af3318773 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php @@ -20,7 +20,7 @@ abstract protected function loadFromFile(ContainerBuilder $container, $file); public function testRolesHierarchy() { - $container = $this->getContainer('hierarchy'); + $container = $this->getContainer('container1'); $this->assertEquals(array( 'ROLE_ADMIN' => array('ROLE_USER'), 'ROLE_SUPER_ADMIN' => array('ROLE_USER', 'ROLE_ADMIN', 'ROLE_ALLOWED_TO_SWITCH'), @@ -30,22 +30,20 @@ public function testRolesHierarchy() public function testUserProviders() { - $container = $this->getContainer('provider'); + $container = $this->getContainer('container1'); - $providers = array_values(array_filter($container->getServiceIds(), function ($key) { return 0 === strpos($key, 'security.authentication.provider.'); })); + $providers = array_values(array_filter($container->getServiceIds(), function ($key) { return 0 === strpos($key, 'security.user.provider.'); })); $expectedProviders = array( - 'security.authentication.provider.digest', - 'security.authentication.provider.digest_23374fce51fe846516ff85bfa9add8fe', - 'security.authentication.provider.basic', - 'security.authentication.provider.basic_745e8583f784c83c4b4208fd281001f3', - 'security.authentication.provider.basic_af4bcce7246fb064b8e219034043d88a', - 'security.authentication.provider.doctrine', - 'security.authentication.provider.service', - 'security.authentication.provider.anonymous', - 'security.authentication.provider.dao', - 'security.authentication.provider.pre_authenticated', - 'security.authentication.provider.rememberme', + 'security.user.provider.default', + 'security.user.provider.default_foo', + 'security.user.provider.digest', + 'security.user.provider.digest_foo', + 'security.user.provider.basic', + 'security.user.provider.basic_foo', + 'security.user.provider.basic_bar', + 'security.user.provider.doctrine', + 'security.user.provider.service', ); $this->assertEquals(array(), array_diff($expectedProviders, $providers)); @@ -54,7 +52,7 @@ public function testUserProviders() public function testFirewalls() { - $container = $this->getContainer('firewall'); + $container = $this->getContainer('container1'); $arguments = $container->getDefinition('security.firewall.map')->getArguments(); $listeners = array(); @@ -82,7 +80,7 @@ public function testFirewalls() public function testAccess() { - $container = $this->getContainer('access'); + $container = $this->getContainer('container1'); $rules = array(); foreach ($container->getDefinition('security.access_map')->getMethodCalls() as $call) { diff --git a/src/Symfony/Component/DependencyInjection/Configuration/ArrayNode.php b/src/Symfony/Component/DependencyInjection/Configuration/ArrayNode.php index f39ccc2ce96e..a9ef74daec20 100644 --- a/src/Symfony/Component/DependencyInjection/Configuration/ArrayNode.php +++ b/src/Symfony/Component/DependencyInjection/Configuration/ArrayNode.php @@ -225,7 +225,7 @@ protected function finalizeValue($value) if ($child->isRequired()) { throw new InvalidConfigurationException(sprintf( 'The node at path "%s" must be configured.', - $this->getPath() + $this->getPath().'.'.$name )); } @@ -352,19 +352,15 @@ protected function mergeValues($leftSide, $rightSide) continue; } - try { - if (null !== $this->prototype) { - $this->prototype->setName($k); - $leftSide[$k] = $this->prototype->merge($leftSide[$k], $v); - } else { - if (!isset($this->children[$k])) { - throw new \RuntimeException('merge() expects a normalized config array.'); - } - - $leftSide[$k] = $this->children[$k]->merge($leftSide[$k], $v); + if (null !== $this->prototype) { + $this->prototype->setName($k); + $leftSide[$k] = $this->prototype->merge($leftSide[$k], $v); + } else { + if (!isset($this->children[$k])) { + throw new \RuntimeException('merge() expects a normalized config array.'); } - } catch (UnsetKeyException $unset) { - unset($leftSide[$k]); + + $leftSide[$k] = $this->children[$k]->merge($leftSide[$k], $v); } } diff --git a/src/Symfony/Component/DependencyInjection/Configuration/Builder/ExprBuilder.php b/src/Symfony/Component/DependencyInjection/Configuration/Builder/ExprBuilder.php index 3c9686448e38..f4c61891bddc 100644 --- a/src/Symfony/Component/DependencyInjection/Configuration/Builder/ExprBuilder.php +++ b/src/Symfony/Component/DependencyInjection/Configuration/Builder/ExprBuilder.php @@ -92,31 +92,6 @@ public function then(\Closure $closure) return $this; } - /** - * Sets a closure replacing the key with an attribute of the value when it is an array. - * - * @param string $attribute - * - * @return Symfony\Component\DependencyInjection\Configuration\Builder\ExprBuilder - */ - public function thenReplaceKeyWithAttribute($attribute) - { - $this->thenPart = function($v) use ($attribute) { - $newValue = array(); - foreach ($v as $k => $oldValue) { - if (is_array($oldValue) && isset($oldValue[$attribute])) { - $k = $oldValue[$attribute]; - } - - $newValue[$k] = $oldValue; - } - - return $newValue; - }; - - return $this; - } - /** * Sets a closure returning an empty array. * diff --git a/src/Symfony/Component/DependencyInjection/Configuration/Builder/NodeBuilder.php b/src/Symfony/Component/DependencyInjection/Configuration/Builder/NodeBuilder.php index 285afa0c4435..7d2dec2df00d 100644 --- a/src/Symfony/Component/DependencyInjection/Configuration/Builder/NodeBuilder.php +++ b/src/Symfony/Component/DependencyInjection/Configuration/Builder/NodeBuilder.php @@ -152,25 +152,6 @@ public function isRequired() return $this; } - /** - * Sets the attribute to use as key of the array. - * - * @param string $attribute The name of the attribute - * - * @return Symfony\Component\DependencyInjection\Configuration\Builder\NodeBuilder - */ - public function containsNameValuePairsWithKeyAttribute($attribute) - { - $this->beforeNormalization() - ->ifArray() - ->thenReplaceKeyWithAttribute($attribute) - ; - - $this->useAttributeAsKey($attribute); - - return $this; - } - /** * Requires the node to have at least one element. * diff --git a/src/Symfony/Component/DependencyInjection/Configuration/Builder/TreeBuilder.php b/src/Symfony/Component/DependencyInjection/Configuration/Builder/TreeBuilder.php index 9c7a56b73dff..71a0132cc918 100644 --- a/src/Symfony/Component/DependencyInjection/Configuration/Builder/TreeBuilder.php +++ b/src/Symfony/Component/DependencyInjection/Configuration/Builder/TreeBuilder.php @@ -128,6 +128,7 @@ protected function configureScalarNode(ScalarNode $configNode, NodeBuilder $node $configNode->addEquivalentValue(null, $node->nullEquivalent); $configNode->addEquivalentValue(true, $node->trueEquivalent); $configNode->addEquivalentValue(false, $node->falseEquivalent); + $configNode->setRequired($node->required); } /** @@ -146,6 +147,7 @@ protected function createArrayConfigNode(NodeBuilder $node) $configNode->addEquivalentValue(true, $node->trueEquivalent); $configNode->addEquivalentValue(false, $node->falseEquivalent); $configNode->setPerformDeepMerging($node->performDeepMerging); + $configNode->setRequired($node->required); if (null !== $node->key) { $configNode->setKeyAttribute($node->key); diff --git a/src/Symfony/Component/DependencyInjection/Configuration/NodeInterface.php b/src/Symfony/Component/DependencyInjection/Configuration/NodeInterface.php index 70271946b46b..67577770913b 100644 --- a/src/Symfony/Component/DependencyInjection/Configuration/NodeInterface.php +++ b/src/Symfony/Component/DependencyInjection/Configuration/NodeInterface.php @@ -19,4 +19,5 @@ function hasDefaultValue(); function getDefaultValue(); function normalize($value); function merge($leftSide, $rightSide); + function finalize($value); } \ No newline at end of file