代码之家  ›  专栏  ›  技术社区  ›  thuiban

参数1已传递给Doctrine\Common\EventManager::addEventSubscriber()

  •  0
  • thuiban  · 技术社区  · 6 年前

    我在加载symfony应用程序时遇到了一些问题:

    php.CRITICAL: Type error: Argument 1 passed to Doctrine\Common\EventManager::addEventSubscriber() must implement interface Doctrine\Common\EventSubscriber, instance of optro\Help\ORM\Listener\MessageElasticaListener
    

    helpdesk.listner.optro:
    class:  Optro\Help\ORM\Listener\MessageElasticaListener
    arguments:
    - '@fos_elastica.object_persister.optro.technical_assistance'
    - '@fos_elastica.indexable'
    - { index: technical_assistance, type: post, identifier: id }
    tags:
    - { name: doctrine.event_listener, event: elastica.index.index_post_populate }
    

    这是我的类MessageElasticaListener:

    use Doctrine\Common\EventArgs;
    use Doctrine\Common\Persistence\Event\LifecycleEventArgs;
    use FOS\ElasticaBundle\Doctrine\Listener as ElasticaListener;
    use optro\Help\Entity\HelpdeskMessage;
    
    class MessageElasticaListener extends ElasticaListener
    {
        /**
        * {@inheritdoc}
        */
    
        private function isObjectIndexable($object)
        {
            return true;
        }
    
        /**
        * {@inheritdoc}
        */
        public function postPersist(LifecycleEventArgs $eventArgs)
        {
            if (!$eventArgs instanceof LifecycleEventArgs) {
                return;
            }
            $entity = $eventArgs->getObject();
            if ($entity instanceof HelpdeskMessage && $this->isObjectIndexable($entity->getTechnicalAssistance())) {
                $this->objectPersister->replaceOne($entity->getTechnicalAssistance());
            }   
        }
    }
    

    怎么了?服务配置错误?

    0 回复  |  直到 4 年前