使用hautelook / alice-bundle时无法加载自定义处理器。
在我的services.yml中:
alice.processor.attendance:
class: MyVendor\MyBundle\DataFixtures\Processor\AttendanceProcessor
arguments: [ "@doctrine.orm.my_entity_manager","@doctrine.orm.second_entity_manager" ]
tags: [ { name: hautelook_alice.alice.processor } ]
MyVendor / MyBundle中的我的文件夹结构:
DataFixtures
| Faker
| ORM
| attendance.yml
| AppFixtures.php
| Processor
| AttendanceProcessor.php
在AttendanceProcessor.php中:
<?php
namespace MyVender\MyBundle\DataFixtures\Processor;
use Nelmio\Alice\ProcessorInterface;
use Isha\HRBundle\Entity\Attendance;
class AttendanceProcessor implements ProcessorInterface
{
protected $em;
protected $suvyaEm;
public function __construct($suvyaEm,$em)
{
var_dump("hello3");
die();
$this->em = $em;
$this->suvyaEm = $suvyaEm;
}
/**
* {@inheritdoc}
*/
public function preProcess($object)
{
var_dump("hello1");
if (false === $object instanceof Attendance) {
return;
}
var_dump("hello1");
die();
}
/**
* {@inheritdoc}
*/
public function postProcess($object)
{
var_dump("hello2");
die();
}
}
最后在AppFixtures.php
<?php
namespace MyVender\MyBundle\DataFixtures\ORM;
use Hautelook\AliceBundle\Doctrine\DataFixtures\AbstractLoader;
use Isha\HRBundle\DataFixtures\Processor\AttendanceProcessor;
use Nelmio\Alice\Fixtures;
class AppFixtures extends AbstractLoader
{
/**
* {@inheritDoc}
*/
public function getFixtures()
{
return array(
__DIR__ . '/attendance.yml',
);
}
}
但没有输出消息。
答案 0 :(得分:0)
服务代码似乎在某些时候发生了变化,当我设置代码fidry_alice_data_fixtures.processor
时,它适用于我。
alice.processor.attendance: class: MyVendor\MyBundle\DataFixtures\Processor\AttendanceProcessor arguments: [ "@doctrine.orm.my_entity_manager","@doctrine.orm.second_entity_manager" ] tags: [ { name: fidry_alice_data_fixtures.processor } ]