Global navigation

   Documentation Center
   eZ Studio & eZ Platform
     User Manual
     Technical Manual
     Glossary
   eZ Publish 4.x / legacy

 
eZ Publish (5.x)

eZ Publish 5.x | For eZ Platform & eZ Studio topics see Technical manual and User manual, for eZ Publish 4.x and Legacy topics see eZ Publish legacy

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

Version compatibility

This recipe is compatible with eZ Publish 5.2 / 2013.07

Description

When you interact with the Public API, and with the content Repository in particular, Signals may be sent out, allowing you to react on actions triggered by the Repository. Those signals can be received by dedicated services called Slots.

To learn more about SignalSlot in eZ Publish, please refer to the dedicated documentation page.

Signals reference

This recipe will describe how to register a Slot for a dedicated Signal.

Registering a Slot for a given Signal

As described in the SignalSlot documentation, a Slot is roughly like an event listener and must extend eZ\Publish\Core\SignalSlot\Slot.

A typical implementation is the following:

OnPublishSlot

OnPublishSlot now needs to be registered as a service in the ServiceContainer and identified as a valid Slot:

services.yml (in your bundle)

Service tag ezpublish.api.slot identifies your service as a valid Slot. The signal part (mandatory) says that this slot is listening to ContentService\PublishVersionSignal (shortcut for \eZ\Publish\Core\SignalSlot\Signal\ContentService\PublishVersionSignal).

Internal signals emitted by Repository services are always relative to eZ\Publish\Core\SignalSlot\Signal namespace.

Hence ContentService\PublishVersionSignal means eZ\Publish\Core\SignalSlot\Signal\ContentService\PublishVersionSignal.

Tip

You can register a slot for any kind of signal by setting signal to * in the service tag.

Using a basic Symfony event listener

eZ Publish comes with a generic slot that converts signals (including ones defined by user code) to regular event objects and expose them via the EventDispatcher. This makes it possible to implement a simple event listener/subscriber if you're more comfortable with this approach.

All you need to do is to implement an event listener or subscriber and register it.

Simple example

This very simple example will just log the received signal.

services.yml (in your bundle)

 

 

  • No labels