Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c0282f3

Browse filesBrowse files
committed
[FrameworkBundle] Fix inconsistensies in Configuration
1 parent b4fbbee commit c0282f3
Copy full SHA for c0282f3

File tree

9 files changed

+77
-56
lines changed
Filter options

9 files changed

+77
-56
lines changed

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+41-56Lines changed: 41 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class FrameworkExtension extends Extension
3737
private $formConfigEnabled = false;
3838
private $translationConfigEnabled = false;
3939
private $sessionConfigEnabled = false;
40+
private $propertyAccessConfigEnabled = false;
4041

4142
/**
4243
* @var string|null
@@ -80,12 +81,17 @@ public function load(array $configs, ContainerBuilder $container)
8081
$loader->load('test.xml');
8182
}
8283

83-
if ($config['session']['enabled']) {
84+
if ($this->isConfigEnabled($container, $config['session'])) {
8485
$this->sessionConfigEnabled = true;
8586
$this->registerSessionConfiguration($config['session'], $container, $loader);
8687
}
8788

88-
if ($config['request']['enabled']) {
89+
if($this->isConfigEnabled($container, $config['property_access'])) {
90+
$this->propertyAccessConfigEnabled = true;
91+
$this->registerPropertyAccessConfiguration($config['property_access'], $container, $loader);
92+
}
93+
94+
if ($this->isConfigEnabled($container, $config['request'])) {
8995
$this->registerRequestConfiguration($config['request'], $container, $loader);
9096
}
9197

@@ -99,38 +105,52 @@ public function load(array $configs, ContainerBuilder $container)
99105
}
100106
}
101107

102-
$this->registerSecurityCsrfConfiguration($config['csrf_protection'], $container, $loader);
108+
if ($this->isConfigEnabled($container, $config['csrf_protection'])) {
109+
$this->registerSecurityCsrfConfiguration($config['csrf_protection'], $container, $loader);
110+
}
103111

104-
if ($config['assets']['enabled']) {
112+
if ($this->isConfigEnabled($container, $config['assets'])) {
105113
$this->registerAssetsConfiguration($config['assets'], $container, $loader);
106114
}
107115

108-
if ($config['templating']['enabled']) {
116+
if ($this->isConfigEnabled($container, $config['templating'])) {
109117
$this->registerTemplatingConfiguration($config['templating'], $config['ide'], $container, $loader);
110118
}
111119

112-
$this->registerValidationConfiguration($config, $container, $loader);
113-
$this->registerEsiConfiguration($config['esi'], $container, $loader);
114-
$this->registerSsiConfiguration($config['ssi'], $container, $loader);
115-
$this->registerFragmentsConfiguration($config['fragments'], $container, $loader);
116-
$this->registerTranslatorConfiguration($config['translator'], $container);
120+
if($this->isConfigEnabled($container, $config['validation'])) {
121+
$this->registerValidationConfiguration($config['validation'], $container, $loader);
122+
}
123+
124+
if($this->isConfigEnabled($container, $config['esi'])) {
125+
$loader->load('esi.xml');
126+
}
127+
128+
if($this->isConfigEnabled($container, $config['ssi'])) {
129+
$loader->load('ssi.xml');
130+
}
131+
132+
if($this->isConfigEnabled($container, $config['fragments'])) {
133+
$this->registerFragmentsConfiguration($config['fragments'], $container, $loader);
134+
}
135+
136+
if($this->isConfigEnabled($container, $config['translator'])) {
137+
$this->translationConfigEnabled = true;
138+
$this->registerTranslatorConfiguration($config['translator'], $container);
139+
}
140+
117141
$this->registerProfilerConfiguration($config['profiler'], $container, $loader);
118142

119-
if ($config['router']['enabled']) {
143+
if ($this->isConfigEnabled($container, $config['router'])) {
120144
$this->registerRouterConfiguration($config['router'], $container, $loader);
121145
}
122146

123147
$this->registerAnnotationsConfiguration($config['annotations'], $container, $loader);
124148

125-
if($this->isConfigEnabled($container, $config['property_access'])) {
126-
$this->registerPropertyAccessConfiguration($config['property_access'], $container, $loader);
127-
}
128-
129-
if (isset($config['serializer'])) {
149+
if ($this->isConfigEnabled($container, $config['serializer'])) {
130150
$this->registerSerializerConfiguration($config, $container, $loader);
131151
}
132152

133-
if (isset($config['property_info'])) {
153+
if ($this->isConfigEnabled($container, $config['property_info'])) {
134154
$this->registerPropertyInfoConfiguration($config['property_info'], $container, $loader);
135155
}
136156

@@ -204,7 +224,7 @@ public function getConfiguration(array $config, ContainerBuilder $container)
204224
*/
205225
private function registerFormConfiguration($config, ContainerBuilder $container, XmlFileLoader $loader)
206226
{
207-
if(!$this->isConfigEnabled($container, $config['property_access'])) {
227+
if(!$this->propertyAccessConfigEnabled) {
208228
throw new LogicException('"framework.property_access" must be enabled when "framework.form" is enabled.');
209229
}
210230

@@ -223,22 +243,6 @@ private function registerFormConfiguration($config, ContainerBuilder $container,
223243
}
224244
}
225245

226-
/**
227-
* Loads the ESI configuration.
228-
*
229-
* @param array $config An ESI configuration array
230-
* @param ContainerBuilder $container A ContainerBuilder instance
231-
* @param XmlFileLoader $loader An XmlFileLoader instance
232-
*/
233-
private function registerEsiConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
234-
{
235-
if (!$this->isConfigEnabled($container, $config)) {
236-
return;
237-
}
238-
239-
$loader->load('esi.xml');
240-
}
241-
242246
/**
243247
* Loads the SSI configuration.
244248
*
@@ -650,11 +654,6 @@ private function createVersion(ContainerBuilder $container, $version, $format, $
650654
*/
651655
private function registerTranslatorConfiguration(array $config, ContainerBuilder $container)
652656
{
653-
if (!$this->isConfigEnabled($container, $config)) {
654-
return;
655-
}
656-
$this->translationConfigEnabled = true;
657-
658657
// Use the "real" translator instead of the identity default
659658
$container->setAlias('translator', 'translator.default');
660659
$translator = $container->findDefinition('translator.default');
@@ -745,16 +744,14 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
745744
*/
746745
private function registerValidationConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
747746
{
748-
if (!$this->isConfigEnabled($container, $config['validation'])) {
747+
if (!$this->isConfigEnabled($container, $config)) {
749748
return;
750749
}
751750

752-
if(!$this->isConfigEnabled($container, $config['property_access'])) {
751+
if(!$this->propertyAccessConfigEnabled) {
753752
throw new LogicException('"framework.property_access" must be enabled when "framework.validator" is enabled.');
754753
}
755754

756-
$config = $config['validation'];
757-
758755
$loader->load('validator.xml');
759756

760757
$validatorBuilder = $container->getDefinition('validator.builder');
@@ -882,10 +879,6 @@ private function registerPropertyAccessConfiguration(array $config, ContainerBui
882879
*/
883880
private function registerSecurityCsrfConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
884881
{
885-
if (!$this->isConfigEnabled($container, $config)) {
886-
return;
887-
}
888-
889882
if (!$this->sessionConfigEnabled) {
890883
throw new \LogicException('CSRF protection needs sessions to be enabled.');
891884
}
@@ -903,11 +896,7 @@ private function registerSecurityCsrfConfiguration(array $config, ContainerBuild
903896
*/
904897
private function registerSerializerConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
905898
{
906-
if (!$config['serializer']['enabled']) {
907-
return;
908-
}
909-
910-
if(!$this->isConfigEnabled($container, $config['property_access'])) {
899+
if(!$this->propertyAccessConfigEnabled) {
911900
throw new LogicException('"framework.property_access" must be enabled when "framework.serializer" is enabled.');
912901
}
913902

@@ -993,10 +982,6 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
993982
*/
994983
private function registerPropertyInfoConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
995984
{
996-
if (!$config['enabled']) {
997-
return;
998-
}
999-
1000985
$loader->load('property_info.xml');
1001986

1002987
if (class_exists('phpDocumentor\Reflection\ClassReflector')) {

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@
188188
</xsd:complexType>
189189

190190
<xsd:complexType name="property_access">
191+
<xsd:attribute name="enabled" type="xsd:boolean" />
191192
<xsd:attribute name="magic-call" type="xsd:boolean" />
192193
<xsd:attribute name="throw-exception-on-invalid-index" type="xsd:boolean" />
193194
</xsd:complexType>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
$container->loadFromExtension('framework', array(
4+
'property_access' => array(
5+
'enabled' => false,
6+
),
7+
));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" ?>
2+
3+
<container xmlns="http://symfony.com/schema/dic/services"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns:framework="http://symfony.com/schema/dic/symfony"
6+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
7+
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
8+
9+
<framework:config>
10+
<framework:property-access enabled="false" />
11+
</framework:config>
12+
</container>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
framework:
2+
property_access:
3+
enabled: false

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ public function testPropertyAccessWithOverriddenValues()
5454
$this->assertTrue($def->getArgument(1));
5555
}
5656

57+
public function testPropertyAccessDisabled()
58+
{
59+
$container = $this->createContainerFromFile('property_accessor_disabled');
60+
$this->assertFalse($container->hasDefinition('property_accessor'));
61+
}
62+
5763
/**
5864
* @expectedException \LogicException
5965
* @expectedExceptionMessage CSRF protection needs sessions to be enabled.

‎src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/framework.yml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/config/framework.yml
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ framework:
1010
session:
1111
storage_id: session.storage.mock_file
1212
profiler: { only_exceptions: false }
13+
property_access: ~
1314

1415
services:
1516
logger: { class: Psr\Log\NullLogger }

‎src/Symfony/Bundle/TwigBundle/Tests/Functional/CacheWarmingTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/Tests/Functional/CacheWarmingTest.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ public function registerContainerConfiguration(LoaderInterface $loader)
9090
$loader->load(function ($container) {
9191
$container->loadFromExtension('framework', array(
9292
'secret' => '$ecret',
93+
94+
// @todo remove this in 4.0
95+
'property_access' => false,
9396
));
9497
});
9598

‎src/Symfony/Bundle/TwigBundle/Tests/Functional/NoTemplatingEntryTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/Tests/Functional/NoTemplatingEntryTest.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ public function registerContainerConfiguration(LoaderInterface $loader)
6262
$loader->load(function ($container) {
6363
$container->loadFromExtension('framework', array(
6464
'secret' => '$ecret',
65+
66+
// @todo remove this in 4.0
67+
'property_access' => false,
6568
));
6669
});
6770
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.