Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix OnEventStrategy #151

Merged
merged 9 commits into from
Jan 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Copyright (c) 2013, Alexander Miertsch contact@prooph.de
Copyright (c) 2013-2017, prooph software GmbH
Copyright (c) 2015-2017, Sascha-Oliver Prolic
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
Expand Down
4 changes: 2 additions & 2 deletions config/prooph_service_bus.config.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This file is part of the prooph/service-bus.
* (c) 2014-2016 prooph software GmbH <contact@prooph.de>
* (c) 2015-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
* (c) 2014-2017 prooph software GmbH <contact@prooph.de>
* (c) 2015-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
4 changes: 2 additions & 2 deletions config/services.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This file is part of the prooph/service-bus.
* (c) 2014-2016 prooph software GmbH <contact@prooph.de>
* (c) 2015-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
* (c) 2014-2017 prooph software GmbH <contact@prooph.de>
* (c) 2015-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
4 changes: 2 additions & 2 deletions examples/quick-start.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This file is part of the prooph/service-bus.
* (c) 2014-2016 prooph software GmbH <contact@prooph.de>
* (c) 2015-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
* (c) 2014-2017 prooph software GmbH <contact@prooph.de>
* (c) 2015-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
4 changes: 2 additions & 2 deletions src/Async/AsyncMessage.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This file is part of the prooph/service-bus.
* (c) 2014-2016 prooph software GmbH <contact@prooph.de>
* (c) 2015-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
* (c) 2014-2017 prooph software GmbH <contact@prooph.de>
* (c) 2015-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
4 changes: 2 additions & 2 deletions src/Async/MessageProducer.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This file is part of the prooph/service-bus.
* (c) 2014-2016 prooph software GmbH <contact@prooph.de>
* (c) 2015-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
* (c) 2014-2017 prooph software GmbH <contact@prooph.de>
* (c) 2015-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
4 changes: 2 additions & 2 deletions src/CommandBus.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This file is part of the prooph/service-bus.
* (c) 2014-2016 prooph software GmbH <contact@prooph.de>
* (c) 2015-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
* (c) 2014-2017 prooph software GmbH <contact@prooph.de>
* (c) 2015-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
4 changes: 2 additions & 2 deletions src/Container/AbstractBusFactory.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This file is part of the prooph/service-bus.
* (c) 2014-2016 prooph software GmbH <contact@prooph.de>
* (c) 2015-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
* (c) 2014-2017 prooph software GmbH <contact@prooph.de>
* (c) 2015-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
4 changes: 2 additions & 2 deletions src/Container/CommandBusFactory.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This file is part of the prooph/service-bus.
* (c) 2014-2016 prooph software GmbH <contact@prooph.de>
* (c) 2015-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
* (c) 2014-2017 prooph software GmbH <contact@prooph.de>
* (c) 2015-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
4 changes: 2 additions & 2 deletions src/Container/EventBusFactory.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This file is part of the prooph/service-bus.
* (c) 2014-2016 prooph software GmbH <contact@prooph.de>
* (c) 2015-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
* (c) 2014-2017 prooph software GmbH <contact@prooph.de>
* (c) 2015-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
4 changes: 2 additions & 2 deletions src/Container/Plugin/Guard/FinalizeGuardFactory.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This file is part of the prooph/service-bus.
* (c) 2014-2016 prooph software GmbH <contact@prooph.de>
* (c) 2015-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
* (c) 2014-2017 prooph software GmbH <contact@prooph.de>
* (c) 2015-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
4 changes: 2 additions & 2 deletions src/Container/Plugin/Guard/RouteGuardFactory.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This file is part of the prooph/service-bus.
* (c) 2014-2016 prooph software GmbH <contact@prooph.de>
* (c) 2015-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
* (c) 2014-2017 prooph software GmbH <contact@prooph.de>
* (c) 2015-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
4 changes: 2 additions & 2 deletions src/Container/QueryBusFactory.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This file is part of the prooph/service-bus.
* (c) 2014-2016 prooph software GmbH <contact@prooph.de>
* (c) 2015-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
* (c) 2014-2017 prooph software GmbH <contact@prooph.de>
* (c) 2015-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
4 changes: 2 additions & 2 deletions src/EventBus.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This file is part of the prooph/service-bus.
* (c) 2014-2016 prooph software GmbH <contact@prooph.de>
* (c) 2015-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
* (c) 2014-2017 prooph software GmbH <contact@prooph.de>
* (c) 2015-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
4 changes: 2 additions & 2 deletions src/Exception/CommandDispatchException.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This file is part of the prooph/service-bus.
* (c) 2014-2016 prooph software GmbH <contact@prooph.de>
* (c) 2015-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
* (c) 2014-2017 prooph software GmbH <contact@prooph.de>
* (c) 2015-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
4 changes: 2 additions & 2 deletions src/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This file is part of the prooph/service-bus.
* (c) 2014-2016 prooph software GmbH <contact@prooph.de>
* (c) 2015-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
* (c) 2014-2017 prooph software GmbH <contact@prooph.de>
* (c) 2015-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
4 changes: 2 additions & 2 deletions src/Exception/MessageDispatchException.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This file is part of the prooph/service-bus.
* (c) 2014-2016 prooph software GmbH <contact@prooph.de>
* (c) 2015-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
* (c) 2014-2017 prooph software GmbH <contact@prooph.de>
* (c) 2015-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
4 changes: 2 additions & 2 deletions src/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This file is part of the prooph/service-bus.
* (c) 2014-2016 prooph software GmbH <contact@prooph.de>
* (c) 2015-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
* (c) 2014-2017 prooph software GmbH <contact@prooph.de>
* (c) 2015-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
4 changes: 2 additions & 2 deletions src/Exception/ServiceBusException.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This file is part of the prooph/service-bus.
* (c) 2014-2016 prooph software GmbH <contact@prooph.de>
* (c) 2015-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
* (c) 2014-2017 prooph software GmbH <contact@prooph.de>
* (c) 2015-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
4 changes: 2 additions & 2 deletions src/MessageBus.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This file is part of the prooph/service-bus.
* (c) 2014-2016 prooph software GmbH <contact@prooph.de>
* (c) 2015-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
* (c) 2014-2017 prooph software GmbH <contact@prooph.de>
* (c) 2015-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
4 changes: 2 additions & 2 deletions src/Plugin/AbstractPlugin.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This file is part of the prooph/service-bus.
* (c) 2014-2016 prooph software GmbH <contact@prooph.de>
* (c) 2015-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
* (c) 2014-2017 prooph software GmbH <contact@prooph.de>
* (c) 2015-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
4 changes: 2 additions & 2 deletions src/Plugin/Guard/AuthorizationService.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This file is part of the prooph/service-bus.
* (c) 2014-2016 prooph software GmbH <contact@prooph.de>
* (c) 2015-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
* (c) 2014-2017 prooph software GmbH <contact@prooph.de>
* (c) 2015-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
4 changes: 2 additions & 2 deletions src/Plugin/Guard/FinalizeGuard.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This file is part of the prooph/service-bus.
* (c) 2014-2016 prooph software GmbH <contact@prooph.de>
* (c) 2015-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
* (c) 2014-2017 prooph software GmbH <contact@prooph.de>
* (c) 2015-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
4 changes: 2 additions & 2 deletions src/Plugin/Guard/RouteGuard.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This file is part of the prooph/service-bus.
* (c) 2014-2016 prooph software GmbH <contact@prooph.de>
* (c) 2015-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
* (c) 2014-2017 prooph software GmbH <contact@prooph.de>
* (c) 2015-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
4 changes: 2 additions & 2 deletions src/Plugin/Guard/UnauthorizedException.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This file is part of the prooph/service-bus.
* (c) 2014-2016 prooph software GmbH <contact@prooph.de>
* (c) 2015-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
* (c) 2014-2017 prooph software GmbH <contact@prooph.de>
* (c) 2015-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
4 changes: 2 additions & 2 deletions src/Plugin/InvokeStrategy/AbstractInvokeStrategy.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This file is part of the prooph/service-bus.
* (c) 2014-2016 prooph software GmbH <contact@prooph.de>
* (c) 2015-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
* (c) 2014-2017 prooph software GmbH <contact@prooph.de>
* (c) 2015-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
4 changes: 2 additions & 2 deletions src/Plugin/InvokeStrategy/FinderInvokeStrategy.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This file is part of the prooph/service-bus.
* (c) 2014-2016 prooph software GmbH <contact@prooph.de>
* (c) 2015-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
* (c) 2014-2017 prooph software GmbH <contact@prooph.de>
* (c) 2015-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
4 changes: 2 additions & 2 deletions src/Plugin/InvokeStrategy/HandleCommandStrategy.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This file is part of the prooph/service-bus.
* (c) 2014-2016 prooph software GmbH <contact@prooph.de>
* (c) 2015-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
* (c) 2014-2017 prooph software GmbH <contact@prooph.de>
* (c) 2015-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
32 changes: 23 additions & 9 deletions src/Plugin/InvokeStrategy/OnEventStrategy.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This file is part of the prooph/service-bus.
* (c) 2014-2016 prooph software GmbH <contact@prooph.de>
* (c) 2015-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
* (c) 2014-2017 prooph software GmbH <contact@prooph.de>
* (c) 2015-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -12,14 +12,28 @@

namespace Prooph\ServiceBus\Plugin\InvokeStrategy;

class OnEventStrategy extends AbstractInvokeStrategy
use Prooph\Common\Event\ActionEvent;
use Prooph\ServiceBus\EventBus;
use Prooph\ServiceBus\MessageBus;
use Prooph\ServiceBus\Plugin\AbstractPlugin;

final class OnEventStrategy extends AbstractPlugin
{
/**
* @param mixed $handler
* @param mixed $message
*/
public function invoke($handler, $message): void
public function attachToMessageBus(MessageBus $messageBus): void
{
$handler->onEvent($message);
$this->listenerHandlers[] = $messageBus->attach(
MessageBus::EVENT_DISPATCH,
function (ActionEvent $actionEvent): void {
$message = $actionEvent->getParam(MessageBus::EVENT_PARAM_MESSAGE);
$handlers = $actionEvent->getParam(EventBus::EVENT_PARAM_EVENT_LISTENERS);

foreach ($handlers as $handler) {
$handler->onEvent($message);
}

$actionEvent->setParam(MessageBus::EVENT_PARAM_MESSAGE_HANDLED, true);
},
MessageBus::PRIORITY_INVOKE_HANDLER
);
}
}
4 changes: 2 additions & 2 deletions src/Plugin/MessageFactoryPlugin.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This file is part of the prooph/service-bus.
* (c) 2014-2016 prooph software GmbH <contact@prooph.de>
* (c) 2015-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
* (c) 2014-2017 prooph software GmbH <contact@prooph.de>
* (c) 2015-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
4 changes: 2 additions & 2 deletions src/Plugin/MessageProducerPlugin.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This file is part of the prooph/service-bus.
* (c) 2014-2016 prooph software GmbH <contact@prooph.de>
* (c) 2015-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
* (c) 2014-2017 prooph software GmbH <contact@prooph.de>
* (c) 2015-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
4 changes: 2 additions & 2 deletions src/Plugin/Plugin.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This file is part of the prooph/service-bus.
* (c) 2014-2016 prooph software GmbH <contact@prooph.de>
* (c) 2015-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
* (c) 2014-2017 prooph software GmbH <contact@prooph.de>
* (c) 2015-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
4 changes: 2 additions & 2 deletions src/Plugin/Router/AsyncSwitchMessageRouter.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* This file is part of the prooph/service-bus.
* (c) 2014-2016 prooph software GmbH <contact@prooph.de>
* (c) 2015-2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
* (c) 2014-2017 prooph software GmbH <contact@prooph.de>
* (c) 2015-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
Loading