[FrameworkBundle] removed the Doctrine Annotations lib dependency on FrameworkBundle

This commit is contained in:
Fabien Potencier 2016-09-29 16:48:22 -07:00
parent fbc8682d96
commit c2d8356cb6
9 changed files with 28 additions and 4 deletions

View File

@ -4,6 +4,8 @@ UPGRADE FROM 3.1 to 3.2
FrameworkBundle
---------------
* The `doctrine/annotations` dependency has been removed; require it via `composer
require doctrine/annotations` if you are using annotations in your project
* The `symfony/security-core` and `symfony/security-csrf` dependencies have
been removed; require them via `composer require symfony/security-core
symfony/security-csrf` if you depend on them and don't already depend on

View File

@ -4,6 +4,7 @@ CHANGELOG
3.2.0
-----
* Removed `doctrine/annotations` from the list of required dependencies in `composer.json`
* Removed `symfony/security-core` and `symfony/security-csrf` from the list of required dependencies in `composer.json`
* Removed `symfony/templating` from the list of required dependencies in `composer.json`
* Removed `symfony/translation` from the list of required dependencies in `composer.json`

View File

@ -593,7 +593,7 @@ class Configuration implements ConfigurationInterface
->children()
->arrayNode('annotations')
->info('annotation configuration')
->addDefaultsIfNotSet()
->canBeDisabled()
->children()
->scalarNode('cache')->defaultValue('php_array')->end()
->scalarNode('file_cache_dir')->defaultValue('%kernel.cache_dir%/annotations')->end()

View File

@ -48,6 +48,7 @@ class FrameworkExtension extends Extension
private $formConfigEnabled = false;
private $translationConfigEnabled = false;
private $sessionConfigEnabled = false;
private $annotationsConfigEnabled = false;
/**
* @var string|null
@ -79,6 +80,8 @@ class FrameworkExtension extends Extension
$configuration = $this->getConfiguration($configs, $container);
$config = $this->processConfiguration($configuration, $configs);
$this->annotationsConfigEnabled = $this->isConfigEnabled($container, $config['annotations']);
// A translator must always be registered (as support is included by
// default in the Form component). If disabled, an identity translator
// will be used and everything will still work as expected.
@ -891,6 +894,10 @@ class FrameworkExtension extends Extension
$definition->replaceArgument(0, $config['strict_email']);
if (array_key_exists('enable_annotations', $config) && $config['enable_annotations']) {
if (!$this->annotationsConfigEnabled) {
throw new \LogicException('"enable_annotations" on the validator cannot be set as Annotations support is disabled.');
}
$validatorBuilder->addMethodCall('enableAnnotationMapping', array(new Reference('annotation_reader')));
}
@ -956,6 +963,14 @@ class FrameworkExtension extends Extension
private function registerAnnotationsConfiguration(array $config, ContainerBuilder $container, $loader)
{
if (!$this->annotationsConfigEnabled) {
return;
}
if (!class_exists('Doctrine\Common\Annotations\Annotation')) {
throw new LogicException('Annotations cannot be enabled as the Doctrine Annotation library is not installed.');
}
$loader->load('annotations.xml');
if ('none' !== $config['cache']) {
@ -1080,6 +1095,10 @@ class FrameworkExtension extends Extension
$serializerLoaders = array();
if (isset($config['enable_annotations']) && $config['enable_annotations']) {
if (!$this->annotationsConfigEnabled) {
throw new \LogicException('"enable_annotations" on the serializer cannot be set as Annotations support is disabled.');
}
$annotationLoader = new Definition(
'Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader',
array(new Reference('annotation_reader'))

View File

@ -188,6 +188,7 @@
<xsd:attribute name="cache" type="xsd:string" />
<xsd:attribute name="debug" type="xsd:string" />
<xsd:attribute name="file-cache-dir" type="xsd:string" />
<xsd:attribute name="enabled" type="xsd:boolean" />
</xsd:complexType>
<xsd:complexType name="property_access">

View File

@ -25,7 +25,6 @@
<service id="kernel.class_cache.cache_warmer" class="Symfony\Bundle\FrameworkBundle\CacheWarmer\ClassCacheCacheWarmer">
<tag name="kernel.cache_warmer" />
<argument type="collection">
<argument>Doctrine\Common\Annotations\AnnotationRegistry</argument>
<argument>Symfony\Component\HttpFoundation\ParameterBag</argument>
<argument>Symfony\Component\HttpFoundation\HeaderBag</argument>
<argument>Symfony\Component\HttpFoundation\FileBag</argument>

View File

@ -216,6 +216,7 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
'cache' => 'php_array',
'file_cache_dir' => '%kernel.cache_dir%/annotations',
'debug' => true,
'enabled' => true,
),
'serializer' => array(
'enabled' => false,

View File

@ -29,8 +29,7 @@
"symfony/finder": "~2.8|~3.0",
"symfony/routing": "~3.0",
"symfony/stopwatch": "~2.8|~3.0",
"doctrine/cache": "~1.0",
"doctrine/annotations": "~1.0"
"doctrine/cache": "~1.0"
},
"require-dev": {
"symfony/asset": "~2.8|~3.0",
@ -51,6 +50,7 @@
"symfony/validator": "~3.2",
"symfony/yaml": "~3.2",
"symfony/property-info": "~2.8|~3.0",
"doctrine/annotations": "~1.0",
"phpdocumentor/reflection-docblock": "^3.0",
"twig/twig": "~1.23|~2.0"
},

View File

@ -22,6 +22,7 @@
"symfony/polyfill-php70": "~1.0"
},
"require-dev": {
"symfony/asset": "~2.8|~3.0",
"symfony/browser-kit": "~2.8|~3.0",
"symfony/console": "~2.8|~3.0",
"symfony/css-selector": "~2.8|~3.0",