我想創建一個手動提供程序來手動填充我的FOS Elastica索引以解釋一些複雜的聯接。目前,我只是想讓提供者在沒有連接的情況下工作,並且我無法在提供者的構造函數中注入正確的Elastica Type。這裏是我的供應商的構造函數:FOS Elastica手動提供程序服務注入問題
// ...
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文件中的正確參數?或者問題可能完全是其他問題?
嗯,你的解決方案不適合我。鑑於我下面的yaml文件,你知道什麼是正確的語法? – DIMMSum