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

[FrameworkBundle] changed some default configs from canBeEnabled to canBeDisabled #21196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions 3 src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ CHANGELOG
3.3.0
-----

* Changed default configuration for
assets/forms/validation/translation/serialization/csrf from `canBeEnabled()` to
`canBeDisabled()` when Flex is used
* The server:* commands and their associated router files were moved to WebServerBundle
* Translation related services are not loaded anymore when the `framework.translator` option
is disabled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;

use Doctrine\Common\Annotations\Annotation;
use Symfony\Bundle\FullStack;
use Symfony\Component\Asset\Package;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Form\Form;
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Translation\Translator;
use Symfony\Component\Validator\Validation;

/**
* FrameworkExtension configuration structure.
Expand Down Expand Up @@ -139,7 +145,7 @@ private function addFormSection(ArrayNodeDefinition $rootNode)
->children()
->arrayNode('form')
->info('form configuration')
->canBeEnabled()
->{!class_exists(FullStack::class) && class_exists(Form::class) ? 'canBeDisabled' : 'canBeEnabled'}()
->children()
->arrayNode('csrf_protection')
->treatFalseLike(array('enabled' => false))
Expand Down Expand Up @@ -506,7 +512,7 @@ private function addAssetsSection(ArrayNodeDefinition $rootNode)
->children()
->arrayNode('assets')
->info('assets configuration')
->canBeEnabled()
->{!class_exists(FullStack::class) && class_exists(Package::class) ? 'canBeDisabled' : 'canBeEnabled'}()
->fixXmlConfig('base_url')
->children()
->scalarNode('version_strategy')->defaultNull()->end()
Expand Down Expand Up @@ -573,7 +579,7 @@ private function addTranslatorSection(ArrayNodeDefinition $rootNode)
->children()
->arrayNode('translator')
->info('translator configuration')
->canBeEnabled()
->{!class_exists(FullStack::class) && class_exists(Translator::class) ? 'canBeDisabled' : 'canBeEnabled'}()
->fixXmlConfig('fallback')
->fixXmlConfig('path')
->children()
Expand All @@ -598,10 +604,10 @@ private function addValidationSection(ArrayNodeDefinition $rootNode)
->children()
->arrayNode('validation')
->info('validation configuration')
->canBeEnabled()
->{!class_exists(FullStack::class) && class_exists(Validation::class) ? 'canBeDisabled' : 'canBeEnabled'}()
->children()
->scalarNode('cache')->end()
->booleanNode('enable_annotations')->defaultFalse()->end()
->booleanNode('enable_annotations')->{!class_exists(FullStack::class) && class_exists(Annotation::class) ? 'defaultTrue' : 'defaultFalse'}()->end()
->arrayNode('static_method')
->defaultValue(array('loadValidatorMetadata'))
->prototype('scalar')->end()
Expand Down Expand Up @@ -642,9 +648,9 @@ private function addSerializerSection(ArrayNodeDefinition $rootNode)
->children()
->arrayNode('serializer')
->info('serializer configuration')
->canBeEnabled()
->{!class_exists(FullStack::class) && class_exists(Serializer::class) ? 'canBeDisabled' : 'canBeEnabled'}()
->children()
->booleanNode('enable_annotations')->defaultFalse()->end()
->booleanNode('enable_annotations')->{!class_exists(FullStack::class) && class_exists(Annotation::class) ? 'defaultTrue' : 'defaultFalse'}()->end()
->scalarNode('cache')->end()
->scalarNode('name_converter')->end()
->end()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection;

use Symfony\Bundle\FrameworkBundle\DependencyInjection\Configuration;
use Symfony\Bundle\FullStack;
use Symfony\Component\Config\Definition\Processor;

class ConfigurationTest extends \PHPUnit_Framework_TestCase
Expand Down Expand Up @@ -176,7 +177,7 @@ protected static function getBundleDefaultConfig()
'enabled' => false,
),
'form' => array(
'enabled' => false,
'enabled' => !class_exists(FullStack::class),
'csrf_protection' => array(
'enabled' => null, // defaults to csrf_protection.enabled
'field_name' => '_token',
Expand All @@ -200,14 +201,14 @@ protected static function getBundleDefaultConfig()
),
),
'translator' => array(
'enabled' => false,
'enabled' => !class_exists(FullStack::class),
'fallbacks' => array('en'),
'logging' => true,
'paths' => array(),
),
'validation' => array(
'enabled' => false,
'enable_annotations' => false,
'enabled' => !class_exists(FullStack::class),
'enable_annotations' => !class_exists(FullStack::class),
'static_method' => array('loadValidatorMetadata'),
'translation_domain' => 'validators',
'strict_email' => false,
Expand All @@ -219,8 +220,8 @@ protected static function getBundleDefaultConfig()
'enabled' => true,
),
'serializer' => array(
'enabled' => false,
'enable_annotations' => false,
'enabled' => !class_exists(FullStack::class),
'enable_annotations' => !class_exists(FullStack::class),
),
'property_access' => array(
'magic_call' => false,
Expand Down Expand Up @@ -258,7 +259,7 @@ protected static function getBundleDefaultConfig()
'loaders' => array(),
),
'assets' => array(
'enabled' => false,
'enabled' => !class_exists(FullStack::class),
'version_strategy' => null,
'version' => null,
'version_format' => '%%s?%%s',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection;

use Doctrine\Common\Annotations\Annotation;
use Symfony\Bundle\FullStack;
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension;
use Symfony\Component\Cache\Adapter\ApcuAdapter;
Expand All @@ -24,6 +26,7 @@
use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Serializer\Mapping\Factory\CacheClassMetadataFactory;
use Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader;
use Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader;
Expand Down Expand Up @@ -413,7 +416,9 @@ public function testValidation()

$calls = $container->getDefinition('validator.builder')->getMethodCalls();

$this->assertCount(6, $calls);
$annotations = !class_exists(FullStack::class) && class_exists(Annotation::class);

$this->assertCount($annotations ? 7 : 6, $calls);
$this->assertSame('setConstraintValidatorFactory', $calls[0][0]);
$this->assertEquals(array(new Reference('validator.validator_factory')), $calls[0][1]);
$this->assertSame('setTranslator', $calls[1][0]);
Expand All @@ -422,10 +427,14 @@ public function testValidation()
$this->assertSame(array('%validator.translation_domain%'), $calls[2][1]);
$this->assertSame('addXmlMappings', $calls[3][0]);
$this->assertSame(array($xmlMappings), $calls[3][1]);
$this->assertSame('addMethodMapping', $calls[4][0]);
$this->assertSame(array('loadValidatorMetadata'), $calls[4][1]);
$this->assertSame('setMetadataCache', $calls[5][0]);
$this->assertEquals(array(new Reference('validator.mapping.cache.symfony')), $calls[5][1]);
$i = 3;
if ($annotations) {
$this->assertSame('enableAnnotationMapping', $calls[++$i][0]);
}
$this->assertSame('addMethodMapping', $calls[++$i][0]);
$this->assertSame(array('loadValidatorMetadata'), $calls[$i][1]);
$this->assertSame('setMetadataCache', $calls[++$i][0]);
$this->assertEquals(array(new Reference('validator.mapping.cache.symfony')), $calls[$i][1]);
}

public function testValidationService()
Expand Down Expand Up @@ -536,10 +545,16 @@ public function testValidationNoStaticMethod()

$calls = $container->getDefinition('validator.builder')->getMethodCalls();

$this->assertCount(5, $calls);
$annotations = !class_exists(FullStack::class) && class_exists(Annotation::class);

$this->assertCount($annotations ? 6 : 5, $calls);
$this->assertSame('addXmlMappings', $calls[3][0]);
$this->assertSame('setMetadataCache', $calls[4][0]);
$this->assertEquals(array(new Reference('validator.mapping.cache.symfony')), $calls[4][1]);
$i = 3;
if ($annotations) {
$this->assertSame('enableAnnotationMapping', $calls[++$i][0]);
}
$this->assertSame('setMetadataCache', $calls[++$i][0]);
$this->assertEquals(array(new Reference('validator.mapping.cache.symfony')), $calls[$i][1]);
// no cache, no annotations, no static methods
}

Expand Down Expand Up @@ -572,7 +587,7 @@ public function testStopwatchEnabledWithDebugModeDisabled()
public function testSerializerDisabled()
{
$container = $this->createContainerFromFile('default_config');
$this->assertFalse($container->has('serializer'));
$this->assertSame(!class_exists(FullStack::class) && class_exists(Serializer::class), $container->has('serializer'));
}

public function testSerializerEnabled()
Expand Down
21 changes: 21 additions & 0 deletions 21 src/Symfony/Bundle/FullStack.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Bundle;

/**
* A marker to be able to check if symfony/symfony is installed instead of the individual components/bundles.
*
* @internal
*/
final class FullStack
{
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.