Skip to content
Snippets Groups Projects
Commit 2aa141a2 authored by David Maus's avatar David Maus
Browse files

Define and use event identifiers

* VuFindSearch/Service.php (EVENT_PRE, EVENT_POST, EVENT_ERROR,
EVENT_RESOLVE): Define constants for event identifiers.
(triggerPre, triggerPost, triggerError, resolve): Use event
identifiers.
parent 37cdcb4b
No related merge requests found
......@@ -48,6 +48,15 @@ use Zend\EventManager\EventManager;
*/
class Service
{
/**
* Event identifiers.
*
* @var string
*/
const EVENT_PRE = 'pre';
const EVENT_POST = 'post';
const EVENT_ERROR = 'error';
const EVENT_RESOLVE = 'resolve';
/**
* Event manager.
......@@ -273,7 +282,7 @@ class Service
{
if (!isset($this->backends[$backend])) {
$response = $this->getEventManager()->trigger(
"resolve",
self::EVENT_RESOLVE,
$this,
$args,
function ($o) {
......@@ -303,7 +312,7 @@ class Service
*/
public function triggerError(BackendException $exception, $args)
{
$this->getEventManager()->trigger('error', $exception, $args);
$this->getEventManager()->trigger(self::EVENT_ERROR, $exception, $args);
}
/**
......@@ -316,7 +325,7 @@ class Service
*/
protected function triggerPre(BackendInterface $backend, $args)
{
$this->getEventManager()->trigger('pre', $backend, $args);
$this->getEventManager()->trigger(self::EVENT_PRE, $backend, $args);
}
/**
......@@ -329,7 +338,7 @@ class Service
*/
protected function triggerPost($response, $args)
{
$this->getEventManager()->trigger('post', $response, $args);
$this->getEventManager()->trigger(self::EVENT_POST, $response, $args);
}
/**
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment