diff --git a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
index 0f5b66521c2b8..064d06f0469d9 100644
--- a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
+++ b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
@@ -5,6 +5,7 @@ CHANGELOG
-----
* Added `Controller::isCsrfTokenValid` helper
+ * Added configuration for the PropertyAccess component
2.5.0
-----
diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
index 8e0927cff1491..0a7e2cc4cd495 100644
--- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
+++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
@@ -92,6 +92,7 @@ public function getConfigTreeBuilder()
$this->addValidationSection($rootNode);
$this->addAnnotationsSection($rootNode);
$this->addSerializerSection($rootNode);
+ $this->addPropertyAccessSection($rootNode);
return $treeBuilder;
}
@@ -524,4 +525,20 @@ private function addSerializerSection(ArrayNodeDefinition $rootNode)
->end()
;
}
+
+ private function addPropertyAccessSection(ArrayNodeDefinition $rootNode)
+ {
+ $rootNode
+ ->children()
+ ->arrayNode('property_access')
+ ->addDefaultsIfNotSet()
+ ->info('Property access configuration')
+ ->children()
+ ->booleanNode('magic_call')->defaultFalse()->end()
+ ->booleanNode('throw_exception_on_invalid_index')->defaultFalse()->end()
+ ->end()
+ ->end()
+ ->end()
+ ;
+ }
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
index df2b60326d069..4aa7cef82fd1e 100644
--- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
@@ -133,6 +133,8 @@ public function load(array $configs, ContainerBuilder $container)
$this->registerAnnotationsConfiguration($config['annotations'], $container, $loader);
+ $this->registerPropertyAccessConfiguration($config['property_access'], $container);
+
if (isset($config['serializer']) && $config['serializer']['enabled']) {
$loader->load('serializer.xml');
}
@@ -818,6 +820,15 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde
}
}
+ private function registerPropertyAccessConfiguration(array $config, ContainerBuilder $container)
+ {
+ $container
+ ->getDefinition('property_accessor')
+ ->replaceArgument(0, $config['magic_call'])
+ ->replaceArgument(1, $config['throw_exception_on_invalid_index'])
+ ;
+ }
+
/**
* Loads the security configuration.
*
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/property_access.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/property_access.xml
index 18026144e4573..0e0fc65dea10d 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/property_access.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/property_access.xml
@@ -9,6 +9,9 @@
-
+
+
+
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
index 4d37c96e1314a..065846f1d357e 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
@@ -30,6 +30,7 @@
+
@@ -177,4 +178,9 @@
+
+
+
+
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php
index 937741c091e0e..58a55c46dbc3a 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php
@@ -139,7 +139,11 @@ protected static function getBundleDefaultConfig()
),
'serializer' => array(
'enabled' => false
- )
+ ),
+ 'property_access' => array(
+ 'magic_call' => false,
+ 'throw_exception_on_invalid_index' => false,
+ ),
);
}
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/property_accessor.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/property_accessor.php
new file mode 100644
index 0000000000000..4340e61fc0961
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/property_accessor.php
@@ -0,0 +1,8 @@
+loadFromExtension('framework', array(
+ 'property_access' => array(
+ 'magic_call' => true,
+ 'throw_exception_on_invalid_index' => true,
+ ),
+));
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/property_accessor.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/property_accessor.xml
new file mode 100644
index 0000000000000..d7db78a6e2e38
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/property_accessor.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/property_accessor.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/property_accessor.yml
new file mode 100644
index 0000000000000..b5fd2718ab112
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/property_accessor.yml
@@ -0,0 +1,4 @@
+framework:
+ property_access:
+ magic_call: true
+ throw_exception_on_invalid_index: true
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
index 7bd57457d9e02..b4ecfa68bed5f 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
@@ -34,6 +34,23 @@ public function testCsrfProtection()
$this->assertEquals('%form.type_extension.csrf.field_name%', $def->getArgument(2));
}
+ public function testPropertyAccessWithDefaultValue()
+ {
+ $container = $this->createContainerFromFile('full');
+
+ $def = $container->getDefinition('property_accessor');
+ $this->assertEquals(false, $def->getArgument(0));
+ $this->assertEquals(false, $def->getArgument(1));
+ }
+
+ public function testPropertyAccessWithOverriddenValues()
+ {
+ $container = $this->createContainerFromFile('property_accessor');
+ $def = $container->getDefinition('property_accessor');
+ $this->assertEquals(true, $def->getArgument(0));
+ $this->assertEquals(true, $def->getArgument(1));
+ }
+
/**
* @expectedException \LogicException
* @expectedExceptionMessage CSRF protection needs sessions to be enabled.