-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
154 additions
and
35 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
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
58 changes: 58 additions & 0 deletions
58
src/Prooph/ServiceBus/Message/AbstractMessageFactoryFactory.php
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,58 @@ | ||
<?php | ||
/* | ||
* This file is part of the prooph/service-bus. | ||
* (c) Alexander Miertsch <contact@prooph.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Date: 05.07.14 - 23:11 | ||
*/ | ||
|
||
namespace Prooph\ServiceBus\Message; | ||
|
||
use Prooph\ServiceBus\Service\MessageFactoryLoader; | ||
use Zend\ServiceManager\AbstractFactoryInterface; | ||
use Zend\ServiceManager\ServiceLocatorInterface; | ||
|
||
/** | ||
* Class AbstractMessageFactoryFactory | ||
* | ||
* @package Prooph\ServiceBus\Message | ||
* @author Alexander Miertsch <kontakt@codeliner.ws> | ||
*/ | ||
class AbstractMessageFactoryFactory implements AbstractFactoryInterface | ||
{ | ||
protected $messageFactory; | ||
|
||
/** | ||
* Determine if we can create a service with name | ||
* | ||
* @param ServiceLocatorInterface $serviceLocator | ||
* @param $name | ||
* @param $requestedName | ||
* @return bool | ||
*/ | ||
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName) | ||
{ | ||
return $serviceLocator instanceof MessageFactoryLoader; | ||
} | ||
|
||
/** | ||
* Create service with name | ||
* | ||
* @param ServiceLocatorInterface $serviceLocator | ||
* @param $name | ||
* @param $requestedName | ||
* @return mixed | ||
*/ | ||
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName) | ||
{ | ||
if (is_null($this->messageFactory)) { | ||
$this->messageFactory = new MessageFactory(); | ||
} | ||
|
||
return $this->messageFactory; | ||
} | ||
} | ||
|
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
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,60 @@ | ||
<?php | ||
/* | ||
* This file is part of the prooph/service-bus. | ||
* (c) Alexander Miertsch <contact@prooph.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Date: 05.07.14 - 23:10 | ||
*/ | ||
|
||
namespace Prooph\ServiceBus\Service; | ||
|
||
use Prooph\ServiceBus\Message\AbstractMessageFactoryFactory; | ||
use Prooph\ServiceBus\Message\MessageFactoryInterface; | ||
use Zend\ServiceManager\AbstractPluginManager; | ||
use Zend\ServiceManager\ConfigInterface; | ||
use Zend\ServiceManager\Exception; | ||
|
||
/** | ||
* Class MessageFactoryLoader | ||
* | ||
* @package Prooph\ServiceBus\Service | ||
* @author Alexander Miertsch <kontakt@codeliner.ws> | ||
*/ | ||
class MessageFactoryLoader extends AbstractPluginManager | ||
{ | ||
|
||
/** | ||
* @param ConfigInterface $aConfig | ||
*/ | ||
public function __construct(ConfigInterface $aConfig = null) | ||
{ | ||
parent::__construct($aConfig); | ||
|
||
$this->abstractFactories[] = new AbstractMessageFactoryFactory(); | ||
} | ||
|
||
/** | ||
* Validate the plugin | ||
* | ||
* Checks that the filter loaded is either a valid callback or an instance | ||
* of FilterInterface. | ||
* | ||
* @param mixed $plugin | ||
* @throws Exception\RuntimeException | ||
* @return void | ||
*/ | ||
public function validatePlugin($plugin) | ||
{ | ||
if (! $plugin instanceof MessageFactoryInterface) { | ||
throw new Exception\RuntimeException(sprintf( | ||
'MessageFactory must be instance of Prooph\ServiceBus\Message\MessageFactoryInterface,' | ||
. 'instance of type %s given', | ||
((is_object($plugin)? get_class($plugin) : gettype($plugin))) | ||
)); | ||
} | ||
} | ||
} | ||
|
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
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