2016-08-03 17 views
0

電子メールイベントをある場所に保存するためのメールキューバンドルを作成し、後で取り上げて処理します。私たちは、マンドリルなどのサービスを使用しないためです。Doctrineに依存し、エンティティを提供するsymfonyバンドルを書くにはどうしたらいいですか?

私のバンドルはBufferedDatabaseMailQueueを発送するので、私のバンドルには追加のエンティティを提供したいと思います。とにかく、私はこのエラーメッセージで終わる

doctrine: 
orm: 
    auto_mapping: false 
    mappings: 
     AcmeDemoBundle: 
      type: annotation 
      alias: MyMailQueueBundle 
      prefix: MyMailQueueBundle\Entity 
      dir: %kernel.root_dir%/../src/MyMailQueueBundle/Entity 
      is_bundle: true 

InvalidArgumentExceptionでため私は、バンドルのconfig.ymlで、次の(まだテストされていない)行を含め、いくつかの研究に

YamlFileLoader.php 404:doctrineのコンフィグレーションをロードできる 拡張はありません

Research 、PrependExtensionInterfaceが何とか私を助けてくれるかもしれないと指摘しました。しかし、私はそれを正しく使用し構成する方法を知らない。私のバンドルは教義に基づいています。

どうすればよいですか?

+1

通常のもののこの種は、アプリケーションのconfig.ymlに行くだろう。 – Cerad

+0

しかしバンドルXYストアエンティティはバンドルインターナショナルではありませんか? –

+0

ほとんどのバンドルは、config.ymlにこれらの行を追加するようにユーザに求めます。ここのstep3を参照してください:https://symfony.com/doc/master/bundles/StofDoctrineExtensionsBundle/index.html – Alsatian

答えて

0

私はこのコードを使用して管理:

<?php 

namespace AltergearMailQueueBundle; 

use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass; 
use Symfony\Component\DependencyInjection\ContainerBuilder; 
use Symfony\Component\HttpKernel\Bundle\Bundle; 
class MyMailQueueBundle extends Bundle 
{ 
    public function build(ContainerBuilder $container) 
    { 
     /* 
     * To extend the bundle to work with mongoDB and couchDB you can follow this tutorial 
     * http://symfony.com/doc/current/doctrine/mapping_model_classes.html 
     * */ 

     parent::build($container); 
     $ormCompilerClass = 'Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass'; 

     if (class_exists($ormCompilerClass)) 
     { 

      $namespaces = array('MyMailQueueBundle\Entity'); 
      $directories = array(realpath(__DIR__.'/Entity')); 
      $managerParameters = array(); 
      $enabledParameter = false; 
      $aliasMap = array('MyMailQueueBundle' => 'MyMailQueueBundle\Entity'); 
      $container->addCompilerPass(
       DoctrineOrmMappingsPass::createAnnotationMappingDriver(
         $namespaces, 
         $directories, 
         $managerParameters, 
         $enabledParameter, 
         $aliasMap 
       ) 
      ); 
     } 


    } 
}