From 04fa5347521cf5596e2753a8a690d2448869bc3a Mon Sep 17 00:00:00 2001 From: automatix Date: Sun, 29 Apr 2018 20:10:52 +0200 Subject: [PATCH] #5 Everything renamed again. Now the event handling system seems to be coherent. --- config/dependencies/common.php | 17 ++++++++--------- .../Website/Controller/QuestController.php | 8 ++++---- .../AbstractProcessEventHandler.php} | 6 +++--- .../PoiHandler.php} | 4 ++-- .../QuestHandler.php} | 4 ++-- .../StepHandler.php} | 4 ++-- .../AbstractStateEventHandler.php | 7 +++++++ .../Quest/Access/empty | 0 .../Quest/AccessFailedHandler.php | 6 +++--- .../Quest/AccessProcessingHandler.php | 6 +++--- .../Quest/CompletedHandler.php | 6 +++--- .../Quest/Completion/empty | 0 .../Quest/FinishedHandler.php | 6 +++--- .../Quest/PlayingHandler.php | 6 +++--- .../Quest/Poi/StartedHandler.php | 6 +++--- .../Quest/Poi/Step/StartedHandler.php | 6 +++--- .../Quest/StartedHandler.php | 6 +++--- .../StateHandlerInterface.php | 2 +- ...{EventHandler.php => SystemEventHandler.php} | 4 ++-- 19 files changed, 55 insertions(+), 49 deletions(-) rename src/Process/{Listeners/AbstractProcessListener.php => ProcessEventHandlers/AbstractProcessEventHandler.php} (87%) rename src/Process/{Listeners/PoiListener.php => ProcessEventHandlers/PoiHandler.php} (85%) rename src/Process/{Listeners/QuestListener.php => ProcessEventHandlers/QuestHandler.php} (85%) rename src/Process/{Listeners/StepListener.php => ProcessEventHandlers/StepHandler.php} (85%) create mode 100644 src/Process/StateEventHandlers/AbstractStateEventHandler.php rename src/Process/{StateHandlers => StateEventHandlers}/Quest/Access/empty (100%) rename src/Process/{StateHandlers => StateEventHandlers}/Quest/AccessFailedHandler.php (72%) rename src/Process/{StateHandlers => StateEventHandlers}/Quest/AccessProcessingHandler.php (71%) rename src/Process/{StateHandlers => StateEventHandlers}/Quest/CompletedHandler.php (73%) rename src/Process/{StateHandlers => StateEventHandlers}/Quest/Completion/empty (100%) rename src/Process/{StateHandlers => StateEventHandlers}/Quest/FinishedHandler.php (73%) rename src/Process/{StateHandlers => StateEventHandlers}/Quest/PlayingHandler.php (73%) rename src/Process/{StateHandlers => StateEventHandlers}/Quest/Poi/StartedHandler.php (73%) rename src/Process/{StateHandlers => StateEventHandlers}/Quest/Poi/Step/StartedHandler.php (73%) rename src/Process/{StateHandlers => StateEventHandlers}/Quest/StartedHandler.php (73%) rename src/Process/{StateHandlers => StateEventHandlers}/StateHandlerInterface.php (85%) rename src/Process/{EventHandler.php => SystemEventHandler.php} (82%) diff --git a/config/dependencies/common.php b/config/dependencies/common.php index 394aa50..767de3f 100644 --- a/config/dependencies/common.php +++ b/config/dependencies/common.php @@ -1,12 +1,11 @@ DI\autowire(StateManagingServiceInterface::class), - 'process_listener.step' => DI\autowire(StepListener::class), - 'process_listener.poi' => DI\autowire(PoiListener::class), - 'process_listener.quest' => DI\autowire(QuestListener::class), + 'process_listener.step' => DI\autowire(StepHandler::class), + 'process_listener.poi' => DI\autowire(PoiHandler::class), + 'process_listener.quest' => DI\autowire(QuestHandler::class), EventHandlerInterface::class => DI\factory(function(ContainerInterface $container) { $listeners = [ 'process_listener.step', 'process_listener.poi', 'process_listener.quest', ]; - return new EventHandler($container->get(StateManagingServiceInterface::class), $listeners); + return new SystemEventHandler($container->get(StateManagingServiceInterface::class), $listeners); }), ]; diff --git a/src/Interop/Website/Controller/QuestController.php b/src/Interop/Website/Controller/QuestController.php index 3d78dc6..da2ee05 100644 --- a/src/Interop/Website/Controller/QuestController.php +++ b/src/Interop/Website/Controller/QuestController.php @@ -15,8 +15,8 @@ class QuestController extends Controller /** @var StateManagingServiceInterface $stateManagingService */ private $stateManagingService; - /** @var EventHandlerInterface $eventHandler */ - private $eventHandler; + /** @var EventHandlerInterface $systemEventHandler */ + private $systemEventHandler; /** @var EventDispatcherInterface */ private $eventDispatcher; @@ -32,14 +32,14 @@ public function __construct( EventDispatcherInterface $eventDispatcher ) { $this->stateManagingService = $stateManagingService; - $this->eventHandler = $processHandlingService; + $this->systemEventHandler = $processHandlingService; $this->eventDispatcher = $eventDispatcher; } public function processUserMessageAction(Request $request) { $message = $request->get('message'); - $this->eventHandler->handle(new GenericEvent($message), GeneralEventName::USER_MESSAGE_RECEIVED(), $this->eventDispatcher); + $this->systemEventHandler->handle(new GenericEvent($message), GeneralEventName::USER_MESSAGE_RECEIVED(), $this->eventDispatcher); return new Response(); } diff --git a/src/Process/Listeners/AbstractProcessListener.php b/src/Process/ProcessEventHandlers/AbstractProcessEventHandler.php similarity index 87% rename from src/Process/Listeners/AbstractProcessListener.php rename to src/Process/ProcessEventHandlers/AbstractProcessEventHandler.php index 5c9204f..3f7199d 100644 --- a/src/Process/Listeners/AbstractProcessListener.php +++ b/src/Process/ProcessEventHandlers/AbstractProcessEventHandler.php @@ -1,15 +1,15 @@ */ -class AccessFailedHandler implements StateHandlerInterface +class AccessFailedHandler extends AbstractStateEventHandler { public function handle( diff --git a/src/Process/StateHandlers/Quest/AccessProcessingHandler.php b/src/Process/StateEventHandlers/Quest/AccessProcessingHandler.php similarity index 71% rename from src/Process/StateHandlers/Quest/AccessProcessingHandler.php rename to src/Process/StateEventHandlers/Quest/AccessProcessingHandler.php index 0967827..4b3ab6d 100644 --- a/src/Process/StateHandlers/Quest/AccessProcessingHandler.php +++ b/src/Process/StateEventHandlers/Quest/AccessProcessingHandler.php @@ -2,17 +2,17 @@ namespace App\Services\Process\Internal\StateHandlers\Quest; use App\Base\Enums\Processes\EventNames\AbstractEventName; -use App\Process\StateHandlers\StateHandlerInterface; +use App\Process\StateEventHandlers\AbstractStateEventHandler; use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** - * Class AccessProcessingHandler implements StateHandlerInterface + * Class AccessProcessingHandler extends AbstractStateEventHandler * * @package App\Services\Process\Internal\StateHandlers\Quest * @author Ilya Khanataev */ -class AccessProcessingHandler implements StateHandlerInterface +class AccessProcessingHandler extends AbstractStateEventHandler { public function handle( diff --git a/src/Process/StateHandlers/Quest/CompletedHandler.php b/src/Process/StateEventHandlers/Quest/CompletedHandler.php similarity index 73% rename from src/Process/StateHandlers/Quest/CompletedHandler.php rename to src/Process/StateEventHandlers/Quest/CompletedHandler.php index 0005e71..d538afe 100644 --- a/src/Process/StateHandlers/Quest/CompletedHandler.php +++ b/src/Process/StateEventHandlers/Quest/CompletedHandler.php @@ -2,17 +2,17 @@ namespace App\Services\Process\Internal\StateHandlers\Quest; use App\Base\Enums\Processes\EventNames\AbstractEventName; -use App\Process\StateHandlers\StateHandlerInterface; +use App\Process\StateEventHandlers\AbstractStateEventHandler; use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** - * Class CompletedHandler implements StateHandlerInterface + * Class CompletedHandler extends AbstractStateEventHandler * * @package App\Services\Process\Internal\StateHandlers\Quest * @author Ilya Khanataev */ -class CompletedHandler implements StateHandlerInterface +class CompletedHandler extends AbstractStateEventHandler { public function handle( diff --git a/src/Process/StateHandlers/Quest/Completion/empty b/src/Process/StateEventHandlers/Quest/Completion/empty similarity index 100% rename from src/Process/StateHandlers/Quest/Completion/empty rename to src/Process/StateEventHandlers/Quest/Completion/empty diff --git a/src/Process/StateHandlers/Quest/FinishedHandler.php b/src/Process/StateEventHandlers/Quest/FinishedHandler.php similarity index 73% rename from src/Process/StateHandlers/Quest/FinishedHandler.php rename to src/Process/StateEventHandlers/Quest/FinishedHandler.php index fdb03af..7beae59 100644 --- a/src/Process/StateHandlers/Quest/FinishedHandler.php +++ b/src/Process/StateEventHandlers/Quest/FinishedHandler.php @@ -2,17 +2,17 @@ namespace App\Services\Process\Internal\StateHandlers\Quest; use App\Base\Enums\Processes\EventNames\AbstractEventName; -use App\Process\StateHandlers\StateHandlerInterface; +use App\Process\StateEventHandlers\AbstractStateEventHandler; use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** - * Class FinishedHandler implements StateHandlerInterface + * Class FinishedHandler extends AbstractStateEventHandler * * @package App\Services\Process\Internal\StateHandlers\Quest * @author Ilya Khanataev */ -class FinishedHandler implements StateHandlerInterface +class FinishedHandler extends AbstractStateEventHandler { public function handle( diff --git a/src/Process/StateHandlers/Quest/PlayingHandler.php b/src/Process/StateEventHandlers/Quest/PlayingHandler.php similarity index 73% rename from src/Process/StateHandlers/Quest/PlayingHandler.php rename to src/Process/StateEventHandlers/Quest/PlayingHandler.php index ffc8895..19b4c91 100644 --- a/src/Process/StateHandlers/Quest/PlayingHandler.php +++ b/src/Process/StateEventHandlers/Quest/PlayingHandler.php @@ -2,17 +2,17 @@ namespace App\Services\Process\Internal\StateHandlers\Quest; use App\Base\Enums\Processes\EventNames\AbstractEventName; -use App\Process\StateHandlers\StateHandlerInterface; +use App\Process\StateEventHandlers\AbstractStateEventHandler; use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** - * Class PlayingHandler implements StateHandlerInterface + * Class PlayingHandler extends AbstractStateEventHandler * * @package App\Services\Process\Internal\StateHandlers\Quest * @author Ilya Khanataev */ -class PlayingHandler implements StateHandlerInterface +class PlayingHandler extends AbstractStateEventHandler { public function handle( diff --git a/src/Process/StateHandlers/Quest/Poi/StartedHandler.php b/src/Process/StateEventHandlers/Quest/Poi/StartedHandler.php similarity index 73% rename from src/Process/StateHandlers/Quest/Poi/StartedHandler.php rename to src/Process/StateEventHandlers/Quest/Poi/StartedHandler.php index 15f0db9..fb5fcd4 100644 --- a/src/Process/StateHandlers/Quest/Poi/StartedHandler.php +++ b/src/Process/StateEventHandlers/Quest/Poi/StartedHandler.php @@ -2,17 +2,17 @@ namespace App\Services\Process\Internal\StateHandlers\Poi; use App\Base\Enums\Processes\EventNames\AbstractEventName; -use App\Process\StateHandlers\StateHandlerInterface; +use App\Process\StateEventHandlers\AbstractStateEventHandler; use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** - * Class StartedHandler implements StateHandlerInterface + * Class StartedHandler extends AbstractStateEventHandler * * @package App\Services\Process\Internal\StateHandlers\Quest * @author Ilya Khanataev */ -class StartedHandler implements StateHandlerInterface +class StartedHandler extends AbstractStateEventHandler { public function handle( diff --git a/src/Process/StateHandlers/Quest/Poi/Step/StartedHandler.php b/src/Process/StateEventHandlers/Quest/Poi/Step/StartedHandler.php similarity index 73% rename from src/Process/StateHandlers/Quest/Poi/Step/StartedHandler.php rename to src/Process/StateEventHandlers/Quest/Poi/Step/StartedHandler.php index 98e0c92..b59552c 100644 --- a/src/Process/StateHandlers/Quest/Poi/Step/StartedHandler.php +++ b/src/Process/StateEventHandlers/Quest/Poi/Step/StartedHandler.php @@ -2,17 +2,17 @@ namespace App\Services\Process\Internal\StateHandlers\Quest; use App\Base\Enums\Processes\EventNames\AbstractEventName; -use App\Process\StateHandlers\StateHandlerInterface; +use App\Process\StateEventHandlers\AbstractStateEventHandler; use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** - * Class StartedHandler implements StateHandlerInterface + * Class StartedHandler extends AbstractStateEventHandler * * @package App\Services\Process\Internal\StateHandlers\Quest * @author Ilya Khanataev */ -class StartedHandler implements StateHandlerInterface +class StartedHandler extends AbstractStateEventHandler { public function handle( diff --git a/src/Process/StateHandlers/Quest/StartedHandler.php b/src/Process/StateEventHandlers/Quest/StartedHandler.php similarity index 73% rename from src/Process/StateHandlers/Quest/StartedHandler.php rename to src/Process/StateEventHandlers/Quest/StartedHandler.php index 98e0c92..b59552c 100644 --- a/src/Process/StateHandlers/Quest/StartedHandler.php +++ b/src/Process/StateEventHandlers/Quest/StartedHandler.php @@ -2,17 +2,17 @@ namespace App\Services\Process\Internal\StateHandlers\Quest; use App\Base\Enums\Processes\EventNames\AbstractEventName; -use App\Process\StateHandlers\StateHandlerInterface; +use App\Process\StateEventHandlers\AbstractStateEventHandler; use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** - * Class StartedHandler implements StateHandlerInterface + * Class StartedHandler extends AbstractStateEventHandler * * @package App\Services\Process\Internal\StateHandlers\Quest * @author Ilya Khanataev */ -class StartedHandler implements StateHandlerInterface +class StartedHandler extends AbstractStateEventHandler { public function handle( diff --git a/src/Process/StateHandlers/StateHandlerInterface.php b/src/Process/StateEventHandlers/StateHandlerInterface.php similarity index 85% rename from src/Process/StateHandlers/StateHandlerInterface.php rename to src/Process/StateEventHandlers/StateHandlerInterface.php index ceab6f1..9e11944 100644 --- a/src/Process/StateHandlers/StateHandlerInterface.php +++ b/src/Process/StateEventHandlers/StateHandlerInterface.php @@ -1,5 +1,5 @@