From f4952e11fa0e201f0a0572690b69d15120aa2a48 Mon Sep 17 00:00:00 2001 From: Rajan Date: Wed, 21 Dec 2016 10:16:44 +1100 Subject: [PATCH] Added composer dependency and class from Phpforce common package --- composer.json | 3 +- src/Phpforce/Common/AbstractHasDispatcher.php | 52 +++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 src/Phpforce/Common/AbstractHasDispatcher.php diff --git a/composer.json b/composer.json index 338431f..106885e 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,8 @@ ], "require": { "php": ">=5.3.0", - "psr/log": "*" + "psr/log": "*", + "symfony/event-dispatcher": ">=2.1" }, "require-dev": { "doctrine/common": ">=2.3" diff --git a/src/Phpforce/Common/AbstractHasDispatcher.php b/src/Phpforce/Common/AbstractHasDispatcher.php new file mode 100644 index 0000000..66cc014 --- /dev/null +++ b/src/Phpforce/Common/AbstractHasDispatcher.php @@ -0,0 +1,52 @@ +eventDispatcher = $eventDispatcher; + } + /** + * Get event dispatcher + * + * If no event dispatcher is supplied, a new one is created. This one will + * then be used internally by the Accelerate library. + * + * @return EventDispatcherInterface + */ + public function getEventDispatcher() + { + if (null == $this->eventDispatcher) { + $this->eventDispatcher = new EventDispatcher(); + } + return $this->eventDispatcher; + } + /** + * Dispatch an event + * + * @param string $name Name of event: see Events.php + * @param Event $event Event object + * + * @return Event + */ + protected function dispatch($name, Event $event) + { + return $this->getEventDispatcher()->dispatch($name, $event); + } +}