2011-09-16 13 views
0

こんにちは私はSymfony DICを使ってDoctrineを設定しています。 これはDoctrine 2.0で完璧に動作していましたが、v2.1にアップグレードしたいので、以下に示すように追加の設定を追加する必要がありました。Symfony Dependency Injection ContainerでDoctrine 2.1を設定する方法は?

$ reader = new \ Doctrine \ Common \ Annotations \ AnnotationReader();

$reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\'); 
// new code necessary starting here 
$reader->setIgnoreNotImportedAnnotations(true); 
$reader->setEnableParsePhpImports(false); 

私の問題もなく、上記のコードのための私のDIC構成:

<service id="doctrine.metadriver" class="Doctrine\ORM\Mapping\Driver\AnnotationDriver"> 
    <argument type="service"> 
     <argument type="service" id="doctrine.cache" /> 
     <service class="Doctrine\Common\Annotations\AnnotationReader"> 
      <call method="setDefaultAnnotationNamespace"> 
       <argument>Doctrine\ORM\Mapping\</argument> 
      </call> 
      <call method="setIgnoreNotImportedAnnotations"> 
       <argument>TRUE</argument> 
      </call> 
      <call method="setEnableParsePhpImports"> 
       <argument>FALSE</argument> 
      </call> 
     </service> 
    </argument> 
    <argument>%doctrine.entity.path%</argument> 
</service> 

私の質問は、私はDICの設定に以下を追加することができますどのように?

$reader = new \Doctrine\Common\Annotations\CachedReader(
    new \Doctrine\Common\Annotations\IndexedReader($reader), new ArrayCache() 
); 

答えて

1

それは完全に働いた構成ではないかもしれませんが、あなたにいくつかのヒントを与える必要があります。

<service id="annotations.base_reader" 
    class="Doctrine\Common\Annotations\AnnotationReader" 
    public="false"> 
     <call method="setDefaultAnnotationNamespace"> 
      <argument>Doctrine\ORM\Mapping\</argument> 
     </call> 
     <call method="setIgnoreNotImportedAnnotations"> 
      <argument>TRUE</argument> 
     </call> 
     <call method="setEnableParsePhpImports"> 
      <argument>FALSE</argument> 
     </call> 
    </argument> 
</service> 

<service id="annotations.indexed_reader" 
    class="Doctrine\Common\Annotations\IndexedReader" 
    public="false"> 
    <argument type="service" id="annotations.base_reader" /> 
</service> 

<service id="annotations.cached_reader" 
    class="Doctrine\Common\Annotations\CachedReader"> 
    <argument type="service" id="annotations.indexed_reader" /> 
    <argument /> 
</service> 

<service id="annotation_reader" alias="annotations.cached_reader" />  

<service id="doctrine.metadriver" class="Doctrine\ORM\Mapping\Driver\AnnotationDriver"> 
    <argument type="service" id="annotation_reader" /> 
    <argument>%doctrine.entity.path%</argument> 
</service> 
関連する問題