fittinq-pimcore/pimcore-events

This package is abandoned and no longer maintained. The author suggests using the fittinq-pimcore/pimcore-commands package instead.
There is no license information available for the latest version (5.0.0) of this package.

5.0.0 2024-05-02 09:02 UTC

README

Use Pimcore events to setup event dispatchers, listeners and handlers.

Install via composer

composer require fittinq\pimcore-events

Setup examples

Setup Synchronous event dispatcher

Fittinq\PimcoreEvents\Event\Dispatcher\EventDispatcher:
    class: \Fittinq\PimcoreEvents\Event\Dispatcher\SynchronousEventDispatcher
    arguments:
      $eventHandlerRepository: '@Fittinq\PimcoreEvents\Event\Handler\EventHandlerRepository'
      $logger: '@Pimcore\Log\ApplicationLogger'

Setup Asynchronous event dispatcher

# Consuming

Fittinq\PimcoreEvents\Command\ConsumeEventsCommand:
  arguments:
    - '@Pimcore\Log\ApplicationLogger'
    - '@DavidMaes\RabbitMQ\Consumers\Consumer'

DavidMaes\RabbitMQ\Consumers\Consumer:
  arguments:
    - '@DavidMaes\RabbitMQ\Connection'
    - 'object_data.events'
    - 'direct'
    - 'object_data.events'
    - '%env(PIMCORE_ENVIRONMENT)%'
    - '@Fittinq\PimcoreEvents\Event\RabbitMQHandler'

# The EventHandlerRepository is located in services_eventhandlers.yml.
Fittinq\PimcoreEvents\Event\RabbitMQHandler:
  arguments:
    - '@Fittinq\PimcoreEvents\Event\Handler\EventHandlerRepository'
    - '@Pimcore\Log\ApplicationLogger'

# Producing

Fittinq\PimcoreEvents\Event\Dispatcher\EventDispatcher:
  class: Fittinq\PimcoreEvents\Event\Dispatcher\AsynchronousEventDispatcher
  arguments:
    - '@DavidMaes\RabbitMQ\Producers\Producer'
    - '@Pimcore\Log\ApplicationLogger'

DavidMaes\RabbitMQ\Producers\Producer:
  arguments:
    - '@DavidMaes\RabbitMQ\Connection'
    - 'object_data.events'
    - 'direct'
    - '%env(PIMCORE_ENVIRONMENT)%'

Setup Event listeners

Fittinq\PimcoreEvents\Event\Pimcore\DataObjectEventListener:
  arguments:
    - '@Fittinq\PimcoreEvents\Event\Dispatcher\EventDispatcher'
    - '@Fittinq\PimcoreVersioning\ChangedFieldsExtractor'
    - '@Fittinq\PimcoreEvents\Event\Pimcore\MessageFactory'
  tags:
    - name: kernel.event_listener
      event: pimcore.dataobject.postUpdate
      method: onPostUpdate
  calls:
    - method: addEventListener
      arguments:
        - '@serviceA'

    - method: addEventListener
      arguments:
        - '@serviceB'
          
serviceA:
    class: \Fittinq\PimcoreEvents\Event\Listener\DataObjectEventListener
    arguments:
      - 'objectA.example.objectbrick'
      - ['field1', 'field2', 'objectbrick.field1']
      - 'Pimcore\Model\DataObject\ObjectA'
      - ['objectbrick']  #empty if there's no objectbrick
      - '@ObjectADataObjectQuerier'
        
serviceB:
  class: \Fittinq\PimcoreEvents\Event\Listener\DataObjectEventListener
  arguments:
    - 'objectB.example.no.objectbrick'
    - ['field1', 'field2']
    - 'Pimcore\Model\DataObject\Object'
    - []  #empty if there's no objectbrick
    - '@Fittinq\PimcoreDataObject\Objectbricks\ObjectbricksQuerier'

Setup Event Handlers

Fittinq\PimcoreEvents\Event\Handler\EventHandlerRepository:
  calls:
    - method: addEventHandler
      arguments:
        - 'objectA.example.objectbrick'
        - '@HandlerA'
    - method: addEventHandler
      arguments:
        - 'objectB.example.no.objectbrick'
        - '@HandlerB'
HandlerA: ~
  HandlerADecorator:
    class: Fittinq\PimcoreEvents\Event\Handler\LockedDataObjectEventHandlerDecorator
    decorates: AppBundle\HandlerAHandler

HandlerB: ~
  HandlerADecorator:
    class: Fittinq\PimcoreEvents\Event\Handler\LockedDataObjectEventHandlerDecorator
    decorates: AppBundle\HandlerBHandler