-
Notifications
You must be signed in to change notification settings - Fork 0
Events (Server)
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.
All classes that extend Omeka\Api\Adapter\AbstractAdapter
trigger these events. Use the event's getTarget()
to get the adapter object.
- services: The service locator.
- request: The API request.
Triggered before executing any API operation.
- 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.
- 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
.
- 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
.
All classes that extend Omeka\Api\Adapter\AbstractEntityAdapter
trigger these events. Use the event's getTarget()
to get the adapter object.
- 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.
- services: The service locator.
- queryBuilder: The Doctrine query builder.
- request: The API request.
Triggered anytime an adapter attempts to find an entity.
- 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.
- 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.
- 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.
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.
- services: The service locator.
See the preRemove
lifecycle event.
- services: The service locator.
See the postRemove
lifecycle event.
- services: The service locator.
See the prePersist
lifecycle event.
- services: The service locator.
See the postPersist
lifecycle event.
- services: The service locator.
See the preUpdate
lifecycle event.
- services: The service locator.
See the postUpdate
lifecycle event.
Use the event's getTarget()
to get the representation object.
- 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.
- 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.
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.
- services: The service locator.
Triggered within a view layout.
- services: The service locator.
Triggered after show page markup.
- services: The service locator.
Triggered after browse page markup.
- services: The service locator.
Triggered after add page markup.
- services: The service locator.
Triggered after edit page markup.
- 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.
- 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.