2016-07-04 37 views
2

我無法加載自定義處理器,而使用hautelook /愛麗絲捆綁。Hautelook愛麗絲:自定義處理器未加載

在我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

服務標籤似乎在某些時候發生了變化,當我設置標籤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 } ]