forked from comsave/soap-client
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
integrate AbstractHasDispatcher instead of /common require
- Loading branch information
Showing
3 changed files
with
60 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
namespace Phpforce\SoapClient; | ||
|
||
use Symfony\Component\EventDispatcher\EventDispatcherInterface; | ||
use Symfony\Component\EventDispatcher\EventDispatcher; | ||
use Symfony\Contracts\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($event, $name); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters