いくつかの複雑な結合を考慮して、FOS Elastica インデックスを手動で設定する手動プロバイダーを作成しようとしています。現時点では、結合がなくてもプロバイダーを機能させようとしていますが、プロバイダーのコンストラクターに正しい Elastica Type を挿入するのに問題があります。これが私のプロバイダーのコンストラクターです。
// ...
class EmpPosDeptProvider implements ProviderInterface
{
private $em;
protected $type;
public function __construct(Type $type, EntityManager $em)
{
$this->type = $type;
$this->em = $em->getRepository('CcitEmployeesBundle:Position');
}
// ...
ここに私のservices.ymlファイルがあります:
services:
employees.search_provider.empPosDept:
class: Ccit\EmployeesBundle\Search\EmpPosDeptProvider
tags:
- { name: fos_elastica.provider, index: employees, type: empPosDept }
arguments:
- %fos_elastica.type.class%
- @doctrine.orm.entity_manager
実行しようとするphp app/console fos:elastica:populate
と、次のエラーが表示されます。
PHP Catchable fatal error: Argument 1 passed to Ccit\EmployeesBundle\Search
\EmpPosDeptProvider::__construct() must be an instance of Elastica\Type, string given,
called in /vagrant-nfs/employees/app/cache/dev/appDevDebugProjectContainer.php on line 736
and defined in /vagrant-nfs/employees/src/Ccit/EmployeesBundle/Search
/EmpPosDeptProvider.php on line 23
services.yml ファイルで正しい引数として何を指定する必要があるか知っている人はいますか? それとも、問題はまったく別のものでしょうか?