thuiban
thuiban

Reputation: 123

Argument 1 passed to Doctrine\Common\EventManager::addEventSubscriber()

I get some trouble when I would load symfony app:

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

See my service configuration:

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 }

This is my class 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());
        }   
    }
}

What's wrong ? Bad services configuration ?

I use symfony 3.4 and FOS Elasticasearch 5.0.3

Upvotes: 0

Views: 1430

Answers (0)

Related Questions