Skip to content

Commit

Permalink
integrate AbstractHasDispatcher instead of /common require
Browse files Browse the repository at this point in the history
  • Loading branch information
Gyvastis committed Apr 9, 2021
1 parent 8aca465 commit c9cd69d
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"require": {
"php": ">=7.2",
"comsave/common": "^0.1.6",
"symfony/event-dispatcher": "*",
"psr/log": "^1.0"
},
"require-dev": {
Expand Down
59 changes: 59 additions & 0 deletions src/Phpforce/SoapClient/AbstractHasDispatcher.php
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);
}
}

2 changes: 0 additions & 2 deletions src/Phpforce/SoapClient/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

namespace Phpforce\SoapClient;

use Phpforce\Common\AbstractHasDispatcher;
use Phpforce\SoapClient\Soap\SoapClient;
use Phpforce\SoapClient\Result;
use Phpforce\SoapClient\Event;
use Phpforce\SoapClient\Exception;

/**
Expand Down

0 comments on commit c9cd69d

Please sign in to comment.