Skip to content
John Flatness edited this page Feb 2, 2016 · 3 revisions

Below is a list of events that Omeka triggers during critical moments of operation. Modules may attach listeners to these events and extend Omeka's functionality. For example, in Module::attachListeners() you can run custom code after an item is created:

$sharedEventManager->attach(
    'Omeka\Api\Adapter\ItemAdapter',
    'api.create.post',
    function (\Zend\EventManager\Event $event) {
        $response = $this->getParam('response');
        $item = $response->getContent();
        // do something
    }
);

We use Zend Framework's EventManager component, so many questions can be answered by reading the documentation.

API Adapter Events

All classes that extend Omeka\Api\Adapter\AbstractAdapter trigger these events. Use the event's getTarget() to get the adapter object.

api.execute.pre

  • services: The service locator.
  • request: The API request.

Triggered before executing any API operation.

api.execute.post

  • services: The service locator.
  • request: The API request.
  • response: The API response.

Triggered after executing any API operation. Does not trigger if a non-validation exception is thrown during execution.

api.*.pre

  • services: The service locator.
  • request: The API request.

Triggered before executing a particular API operation. Replace the asterisk with one of the following operations: search, create, batch_create, read, update, or delete.

api.*.post

  • services: The service locator.
  • request: The API request.
  • response: The API response.

Triggered after executing a particular API operation. Replace the asterisk with one of the following operations: search, create, batch_create, read, update, or delete.

API Entity Adapter Events

All classes that extend Omeka\Api\Adapter\AbstractEntityAdapter trigger these events. Use the event's getTarget() to get the adapter object.

api.search.query

  • services: The service locator.
  • queryBuilder: The Doctrine query builder.
  • request: The API request.

Triggered during an API search operation, after the adapter builds the initial query.

api.find.query

  • services: The service locator.
  • queryBuilder: The Doctrine query builder.
  • request: The API request.

Triggered anytime an adapter attempts to find an entity.

api.find.post

  • services: The service locator.
  • entity: The found entity.
  • request: The API request.

Triggered during the API read and delete operations, after an entity is found.

api.validate.data.pre

  • services: The service locator.
  • entity: The un-hydrated entity.
  • request: The API request.
  • errorStore: The error store.

Triggered during the API create, batch_create, and update operations, before entity hydration.

api.validate.entity.pre

  • services: The service locator.
  • entity: The hydrated entity.
  • request: The API request.
  • errorStore: The error store.

Triggered during the API create, batch_create, and update operations, after entity hydration.

Doctrine Lifecycle Events

All classes that implement Omeka\Entity\EntityInterface trigger these events. Use the event's getTarget() to get the entity object. These delegate selected Doctrine lifecycle events to Omeka events.

entity.remove.pre

  • services: The service locator.

See the preRemove lifecycle event.

entity.remove.post

  • services: The service locator.

See the postRemove lifecycle event.

entity.persist.pre

  • services: The service locator.

See the prePersist lifecycle event.

entity.persist.post

  • services: The service locator.

See the postPersist lifecycle event.

entity.update.pre

  • services: The service locator.

See the preUpdate lifecycle event.

entity.update.post

  • services: The service locator.

See the postUpdate lifecycle event.

API Representation Events

Use the event's getTarget() to get the representation object.

rep.resource.json

  • services: The service locator.
  • jsonLd: The JSON-LD array.

All classes that extend Omeka\Api\Representation\AbstractRepresentation trigger this event.

Triggered after the serialization of a representation's JSON-LD. To filter the JSON-LD, listeners may modify the jsonLd parameter and set it back to the event.

rep.value.html

  • html: The value text.

The Omeka\Api\Representation\ValueRepresentation class triggers this event. All information about the value is available in the event's target object, including target URL, target ID (for resource value), and label.

Triggered after getting a Value representation's text (for display on a webpage). To filter the text, listeners may modify the html parameter and set it back to the event.

View Events

The trigger view helper triggers these events at strategic locations within view templates. Use the controller's invokable service name as the event identifier. Use the event's getTarget() to get the view renderer. Any markup echoed in listeners will render on page.

view.layout

  • services: The service locator.

Triggered within a view layout.

view.show.after

  • services: The service locator.

Triggered after show page markup.

view.browse.after

  • services: The service locator.

Triggered after browse page markup.

view.add.after

  • services: The service locator.

Triggered after add page markup.

view.edit.after

  • services: The service locator.

Triggered after edit page markup.

Miscellaneous Events

site_settings.form

  • services: The service locator.
  • form: The site settings form.

Triggered in the site admin settings action. Use the event's getTarget() to get the controller object.

service.registered_names

  • services: The service locator.
  • registered_names: An array of registered names.

Triggered when getting the registered names of certain Omeka services (using getRegisteredNames()). Use the event's getTarget() to get the service plugin manager. To filter the names, listeners may modify the registered_names parameter and set it back to the event.