Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Added composer dependency and class from Phpforce common package
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajan authored and Rajan committed Dec 20, 2016
1 parent c3a5f90 commit f4952e1
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
],
"require": {
"php": ">=5.3.0",
"psr/log": "*"
"psr/log": "*",
"symfony/event-dispatcher": ">=2.1"
},
"require-dev": {
"doctrine/common": ">=2.3"
Expand Down
52 changes: 52 additions & 0 deletions src/Phpforce/Common/AbstractHasDispatcher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
namespace Phpforce\Common;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\Event;
/**
* Can be extended by classes that dispatch events using the event dispatcher
*
*/
abstract class AbstractHasDispatcher
{
/**
* @var EventDispatcherInterface
*/
protected $eventDispatcher;
/**
* Set event dispatcher
*
* @param EventDispatcherInterface $eventDispatcher
*/
public function setEventDispatcher(EventDispatcherInterface $eventDispatcher)
{
$this->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);
}
}

0 comments on commit f4952e1

Please sign in to comment.