[英]Symfony / Doctrine EntityListener doesn't work
我的 EntityListener 有問題...我的 EntityListener 沒有被調用,他不工作,我不知道為什么! 我使用 Symfony 3.4 和 Doctrine 2.5。
所以,我的實體:
<?php
namespace TelecomlineBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* LigneTelecom
*
* @ORM\Table(name="LIGNETELECOM")
* @ORM\Entity(repositoryClass="TelecomlineBundle\Repository\LigneTelecomRepository")
* @ORM\EntityListeners({"TelecomlineBundle\Doctrine\Listener\LigneTelecomListener"})
*/
class LigneTelecom
{
// etc ...
}
我的實體監聽器:
<?php
namespace TelecomlineBundle\Doctrine\Listener;
use TelecomlineBundle\Entity\LigneTelecom;
use TelecomlineBundle\Service\myService;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Mapping as ORM;
class LigneTelecomListener
{
/** @var myService $myService */
private $myService;
public function __construct(myService $myService)
{
$this->myService = $myService;
}
/**
* @ORM\PostUpdate()
*
* @param LigneTelecom $ligneTelecom
* @param LifecycleEventArgs $eventArgs
*/
public function postUpdate(LigneTelecom $ligneTelecom, LifecycleEventArgs $eventArgs)
{
$this->myService->calculate($ligneTelecom);
}
// etc ...
我的 service.yml :
telecomline.doctrine.lignetelecom_listener:
class: "TelecomlineBundle\Entity\LigneTelecom"
arguments: ["@telecomline.porte"]
tags:
- { name: doctrine.orm.entity_listener }
如果有人有解決方案,我會在 3 小時后阻止它:'(
您應該指定訂閱者想要收聽的事件使用長形式的定義或從 EventSubscriber 繼承並覆蓋 getSubscribedEvents
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.