Browse Source

updated to latest changes in Doctrine

Johannes Schmitt 14 năm trước cách đây
mục cha
commit
9c0db88851

+ 22 - 0
UPDATE.md

@@ -6,6 +6,28 @@ one. It only discusses changes that need to be done when using the "public"
 API of the framework. If you "hack" the core, you should probably follow the
 timeline closely anyway.
 
+beta2 to beta3
+--------------
+
+* The settings under "framework.annotations" have changed slightly:
+
+  Before:
+  
+    framework:
+        annotations:
+            cache: file
+            file_cache:
+                debug: true
+                dir: /foo
+                
+  After:
+     
+    framework:
+        annotations:
+            cache: file
+            debug: true
+            file_cache_dir: /foo
+
 beta1 to beta2
 --------------
 

+ 2 - 7
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

@@ -274,13 +274,8 @@ class Configuration implements ConfigurationInterface
                     ->addDefaultsIfNotSet()
                     ->children()
                         ->scalarNode('cache')->defaultValue('file')->end()
-                        ->arrayNode('file_cache')
-                            ->addDefaultsIfNotSet()
-                            ->children()
-                                ->scalarNode('dir')->defaultValue('%kernel.cache_dir%/annotations')->end()
-                                ->booleanNode('debug')->defaultValue($this->debug)->end()
-                            ->end()
-                        ->end()
+                        ->scalarNode('file_cache_dir')->defaultValue('%kernel.cache_dir%/annotations')->end()
+                        ->booleanNode('debug')->defaultValue($this->debug)->end()
                     ->end()
                 ->end()
             ->end()

+ 8 - 7
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

@@ -517,23 +517,24 @@ class FrameworkExtension extends Extension
         $loader->load('annotations.xml');
 
         if ('file' === $config['cache']) {
-            $cacheDir = $container->getParameterBag()->resolveValue($config['file_cache']['dir']);
+            $cacheDir = $container->getParameterBag()->resolveValue($config['file_cache_dir']);
             if (!is_dir($cacheDir) && false === @mkdir($cacheDir, 0777, true)) {
                 throw new \RuntimeException(sprintf('Could not create cache directory "%s".', $cacheDir));
             }
 
             $container
-                ->getDefinition('annotations.cache.file_cache')
-                ->replaceArgument(0, $cacheDir)
-                ->replaceArgument(1, $config['file_cache']['debug'])
+                ->getDefinition('annotations.file_cache_reader')
+                ->replaceArgument(1, $cacheDir)
+                ->replaceArgument(2, $config['debug'])
             ;
-        } else if ('none' === $config['cache']) {
-            $container->setAlias('annotation_reader', 'annotations.reader');
-        } else {
+            $container->setAlias('annotation_reader', 'annotations.file_cache_reader');
+        } else if('none' !== $config['cache']) {
             $container
                 ->getDefinition('annotations.cached_reader')
                 ->replaceArgument(1, new Reference($config['cache']))
+                ->replaceArgument(2, $config['debug'])
             ;
+            $container->setAlias('annotation_reader', 'annotations.cached_reader');
         }
     }
 

+ 10 - 9
src/Symfony/Bundle/FrameworkBundle/Resources/config/annotations.xml

@@ -5,25 +5,26 @@
     xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
 
     <parameters>
-        <parameter key="annotations.cache.file_cache.class">Doctrine\Common\Annotations\Cache\FileCache</parameter>
-
         <parameter key="annotations.reader.class">Doctrine\Common\Annotations\AnnotationReader</parameter>
         <parameter key="annotations.cached_reader.class">Doctrine\Common\Annotations\CachedReader</parameter>
+        <parameter key="annotations.file_cache_reader.class">Doctrine\Common\Annotations\FileCacheReader</parameter>
     </parameters>
 
     <services>
-        <service id="annotations.cache.file_cache" class="%annotations.cache.file_cache.class%" public="false">
-            <argument /><!-- Cache Directory -->
-            <argument /><!-- Debug-Flag -->
-        </service>
-
         <service id="annotations.reader" class="%annotations.reader.class%" public="false" />
 
         <service id="annotations.cached_reader" class="%annotations.cached_reader.class%" public="false">
             <argument type="service" id="annotations.reader" />
-            <argument type="service" id="annotations.cache.file_cache" />
+            <argument /><!-- Cache Implementation -->
+            <argument /><!-- Debug-Flag -->
+        </service>
+        
+        <service id="annotations.file_cache_reader" class="%annotations.file_cache_reader.class%" public="false">
+            <argument type="service" id="annotations.reader" />
+            <argument /><!-- Cache-Directory -->
+            <argument /><!-- Debug Flag -->
         </service>
 
-        <service id="annotation_reader" alias="annotations.cached_reader" />
+        <service id="annotation_reader" alias="annotations.reader" />
     </services>
 </container>

+ 1 - 8
src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd

@@ -128,15 +128,8 @@
     </xsd:complexType>
     
     <xsd:complexType name="annotations">
-        <xsd:sequence>
-            <xsd:element name="file-cache" type="annotations.file_cache" minOccurs="0" maxOccurs="1" />
-        </xsd:sequence>
-
         <xsd:attribute name="cache" type="xsd:string" />
-    </xsd:complexType>
-    
-    <xsd:complexType name="annotations.file_cache">
-        <xsd:attribute name="dir" type="xsd:string" />
         <xsd:attribute name="debug" type="xsd:string" />
+        <xsd:attribute name="file-cache-dir" type="xsd:string" />
     </xsd:complexType>
 </xsd:schema>

+ 2 - 4
src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php

@@ -59,9 +59,7 @@ $container->loadFromExtension('framework', array(
     ),
     'annotations' => array(
         'cache' => 'file',
-        'file_cache' => array(
-            'dir'   => '%kernel.cache_dir%/annotations',
-            'debug' => true,
-        )
+        'debug' => true,
+        'file_cache_dir' => '%kernel.cache_dir%/annotations',
     ),
 ));

+ 1 - 3
src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml

@@ -31,8 +31,6 @@
         </framework:templating>
         <framework:translator enabled="true" fallback="fr" />
         <framework:validation enabled="true" cache="apc" />
-        <framework:annotations cache="file">
-            <framework:file-cache dir="%kernel.cache_dir%/annotations" debug="true" />
-        </framework:annotations>
+        <framework:annotations cache="file" debug="true" file-cache-dir="%kernel.cache_dir%/annotations" />
     </framework:config>
 </container>

+ 2 - 3
src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml

@@ -45,6 +45,5 @@ framework:
         cache:   apc
     annotations:
         cache:   file
-        file_cache:
-            dir:   %kernel.cache_dir%/annotations
-            debug: true
+        debug:   true
+        file_cache_dir: %kernel.cache_dir%/annotations

+ 2 - 2
src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

@@ -172,8 +172,8 @@ abstract class FrameworkExtensionTest extends TestCase
     {
         $container = $this->createContainerFromFile('full');
 
-        $this->assertEquals($container->getParameter('kernel.cache_dir').'/annotations', $container->getDefinition('annotations.cache.file_cache')->getArgument(0));
-        $this->assertEquals('annotations.cached_reader', (string) $container->getAlias('annotation_reader'));
+        $this->assertEquals($container->getParameter('kernel.cache_dir').'/annotations', $container->getDefinition('annotations.file_cache_reader')->getArgument(1));
+        $this->assertInstanceOf('Doctrine\Common\Annotations\FileCacheReader', $container->get('annotation_reader'));
     }
 
     public function testValidationAnnotations()