2016-07-25 5 views
1

私は別のバンドルに依存するバンドルを構築しています。私はxbundle.doctrine.factoryパラメータはアプリ/設定/ config.ymlから変更することができますが、私が欲しい知っているanohterバンドルのパラメータをオーバーライド

parameters: 
    xbundle.doctrine.factory: Doctrine\ORM\Repository\DefaultRepositoryFactory 
services: 
    .... 

:親バンドルには、いくつかのパラメータを定義するservices.ymlファイルをロードカスタムの子バンドルからその値を変更する私はread the docs、また提案されたスタックオーバーフローの質問は、まだそれを達成する方法を把握することはできません。

+0

私は便利な例はありませんが、コンパイラパスが必要だと思う:http://symfony.com/doc/current/cookbook/service_container/compiler_passes.html。しかし、あなたが何をしているのか本当に本当に分かっていなければ、デフォルトのdoctrineリポジトリファクトリをオーバーライドしないでください。おそらく、あなたはdoctrineイベントリスナーを使うことができます。 – Cerad

答えて

0

あなたはあなたの子供のバンドルでCompilerPassを書き、その値を変更する必要があります。

// src/Acme/DemoBundle/DependencyInjection/Compiler/OverrideServiceCompilerPass.php 
namespace Acme\DemoBundle\DependencyInjection\Compiler; 

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; 
use Symfony\Component\DependencyInjection\ContainerBuilder; 

class OverrideServiceCompilerPass implements CompilerPassInterface 
{ 
    public function process(ContainerBuilder $container) 
    { 
     $container->setParameter('xbundle.doctrine.factory', '..New Value ...'); 
    } 
} 

一部のマニュアルhereを。

関連する問題