@@ -4,14 +4,14 @@ |
||
| 4 | 4 | use PEIP\INF\Message\Message; |
| 5 | 5 | |
| 6 | 6 | class DrinkRouter |
| 7 | - extends Router {
|
|
| 7 | + extends Router {
|
|
| 8 | 8 | |
| 9 | - protected function selectChannels(Message $message){
|
|
| 10 | - $order = $message->getContent(); |
|
| 11 | - $channelName = $order['iced'] ? 'coldDrinks' : 'hotDrinks'; |
|
| 12 | - echo PEIP_LINE_SEPARATOR."DrinkRouter: routed to channel: $channelName"; |
|
| 13 | - return $channelName; |
|
| 14 | - } |
|
| 9 | + protected function selectChannels(Message $message){
|
|
| 10 | + $order = $message->getContent(); |
|
| 11 | + $channelName = $order['iced'] ? 'coldDrinks' : 'hotDrinks'; |
|
| 12 | + echo PEIP_LINE_SEPARATOR."DrinkRouter: routed to channel: $channelName"; |
|
| 13 | + return $channelName; |
|
| 14 | + } |
|
| 15 | 15 | |
| 16 | 16 | |
| 17 | 17 | } |
@@ -5,20 +5,20 @@ |
||
| 5 | 5 | |
| 6 | 6 | class OrderSplitter extends MessageSplitter {
|
| 7 | 7 | |
| 8 | - public function split(Message $message){
|
|
| 9 | - $order = $message->getContent(); |
|
| 10 | - $orderItems = $order->getItems(); |
|
| 11 | - $items = array(); |
|
| 12 | - foreach($orderItems as $item){
|
|
| 13 | - $nr = $item['number']; |
|
| 14 | - unset($item['number']); |
|
| 15 | - $item['order'] = $order->getOrderNumber(); |
|
| 16 | - for($x = 0; $x < $nr; $x++){
|
|
| 17 | - $items[] = $item; |
|
| 18 | - } |
|
| 19 | - } |
|
| 20 | - echo PEIP_LINE_SEPARATOR."OrderSplitter: split order #: ".$order->getOrderNumber(); |
|
| 21 | - return $items; |
|
| 22 | - } |
|
| 8 | + public function split(Message $message){
|
|
| 9 | + $order = $message->getContent(); |
|
| 10 | + $orderItems = $order->getItems(); |
|
| 11 | + $items = array(); |
|
| 12 | + foreach($orderItems as $item){
|
|
| 13 | + $nr = $item['number']; |
|
| 14 | + unset($item['number']); |
|
| 15 | + $item['order'] = $order->getOrderNumber(); |
|
| 16 | + for($x = 0; $x < $nr; $x++){
|
|
| 17 | + $items[] = $item; |
|
| 18 | + } |
|
| 19 | + } |
|
| 20 | + echo PEIP_LINE_SEPARATOR."OrderSplitter: split order #: ".$order->getOrderNumber(); |
|
| 21 | + return $items; |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | 24 | } |
@@ -1,11 +1,11 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class Cafe |
| 4 | - extends \PEIP\Gateway\SimpleMessagingGateway {
|
|
| 4 | + extends \PEIP\Gateway\SimpleMessagingGateway {
|
|
| 5 | 5 | |
| 6 | - public function placeOrder(Order $order){
|
|
| 7 | - return $this->sendAndReceive($order); |
|
| 8 | - } |
|
| 6 | + public function placeOrder(Order $order){
|
|
| 7 | + return $this->sendAndReceive($order); |
|
| 8 | + } |
|
| 9 | 9 | |
| 10 | 10 | } |
| 11 | 11 | |
@@ -9,9 +9,9 @@ |
||
| 9 | 9 | // simple service class |
| 10 | 10 | class HelloService {
|
| 11 | 11 | |
| 12 | - public function greet($name){
|
|
| 13 | - return 'Hello '.$name; |
|
| 14 | - } |
|
| 12 | + public function greet($name){
|
|
| 13 | + return 'Hello '.$name; |
|
| 14 | + } |
|
| 15 | 15 | |
| 16 | 16 | } |
| 17 | 17 | |
@@ -16,13 +16,13 @@ discard block |
||
| 16 | 16 | use PEIP\Context\XMLContext; |
| 17 | 17 | |
| 18 | 18 | class ServiceFactory {
|
| 19 | - /** |
|
| 20 | - * Creates and initializes service instance from a given configuration. |
|
| 21 | - * |
|
| 22 | - * @access public |
|
| 23 | - * @param $config configuration of the service |
|
| 24 | - * @return object the initialized service instance |
|
| 25 | - */ |
|
| 19 | + /** |
|
| 20 | + * Creates and initializes service instance from a given configuration. |
|
| 21 | + * |
|
| 22 | + * @access public |
|
| 23 | + * @param $config configuration of the service |
|
| 24 | + * @return object the initialized service instance |
|
| 25 | + */ |
|
| 26 | 26 | public static function createService(array $config){
|
| 27 | 27 | $args = array(); |
| 28 | 28 | //build arguments for constructor |
@@ -35,15 +35,15 @@ discard block |
||
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | - * Builds an arbitrary service/object instance from a config-obect. |
|
| 39 | - * |
|
| 40 | - * @static |
|
| 41 | - * @access protected |
|
| 42 | - * @param object $config configuration object to build a service instance from. |
|
| 43 | - * @param array $arguments arguments for the service constructor |
|
| 44 | - * @param string $defaultClass class to create instance for if none is set in config |
|
| 45 | - * @return object build and modified srvice instance |
|
| 46 | - */ |
|
| 38 | + * Builds an arbitrary service/object instance from a config-obect. |
|
| 39 | + * |
|
| 40 | + * @static |
|
| 41 | + * @access protected |
|
| 42 | + * @param object $config configuration object to build a service instance from. |
|
| 43 | + * @param array $arguments arguments for the service constructor |
|
| 44 | + * @param string $defaultClass class to create instance for if none is set in config |
|
| 45 | + * @return object build and modified srvice instance |
|
| 46 | + */ |
|
| 47 | 47 | public static function doBuild($config, $arguments, $defaultClass = false){
|
| 48 | 48 | $cls = isset($config["class"]) ? trim((string)$config["class"]) : (string)$defaultClass; |
| 49 | 49 | if($cls != ''){
|
@@ -80,12 +80,12 @@ discard block |
||
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | - * Builds single argument (to call a method with later) from a config-obect. |
|
| 84 | - * |
|
| 85 | - * @access protected |
|
| 86 | - * @param object $config configuration object to create argument from. |
|
| 87 | - * @return mixed build argument |
|
| 88 | - */ |
|
| 83 | + * Builds single argument (to call a method with later) from a config-obect. |
|
| 84 | + * |
|
| 85 | + * @access protected |
|
| 86 | + * @param object $config configuration object to create argument from. |
|
| 87 | + * @return mixed build argument |
|
| 88 | + */ |
|
| 89 | 89 | protected function buildArg($config){
|
| 90 | 90 | if(trim((string)$config['value']) != ''){
|
| 91 | 91 | $arg = (string)$config['value']; |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | public static function buildAndModify(array $config, $arguments, $defaultClass = ""){
|
| 130 | 130 | if((isset($config["class"]) && "" != (string)$config["class"]) || $defaultClass !== ""){
|
| 131 | - $service = ServiceFactory::doBuild($config, $arguments, $defaultClass); |
|
| 131 | + $service = ServiceFactory::doBuild($config, $arguments, $defaultClass); |
|
| 132 | 132 | }else{
|
| 133 | 133 | throw new \RuntimeException('Could not create Service. no class or reference given.');
|
| 134 | 134 | } |
@@ -127,7 +127,7 @@ |
||
| 127 | 127 | * @param callable $callable a callable which creates instances for node-name |
| 128 | 128 | */ |
| 129 | 129 | public function registerNodeBuilder($nodeName, $callable){ |
| 130 | - return $this->getServiceProvider()->registerNodeBuilder($nodeName, $callable); |
|
| 130 | + return $this->getServiceProvider()->registerNodeBuilder($nodeName, $callable); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -76,11 +76,11 @@ |
||
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | - * returns all headers of the message |
|
| 80 | - * |
|
| 81 | - * @access public |
|
| 82 | - * @return ArrayAccess ArrayAccess object of headers |
|
| 83 | - */ |
|
| 79 | + * returns all headers of the message |
|
| 80 | + * |
|
| 81 | + * @access public |
|
| 82 | + * @return ArrayAccess ArrayAccess object of headers |
|
| 83 | + */ |
|
| 84 | 84 | public function getHeaders(){ |
| 85 | 85 | return (array) $this->headers; |
| 86 | 86 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | */ |
| 75 | 75 | public function setParameters($namespace, array $parameters){ |
| 76 | 76 | $this->getParameterHolderOrCreate($namespace)->setParameters($parameters); |
| 77 | - } |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | 79 | |
| 80 | 80 | /** |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | public function addParameters($namespace, array $parameters){ |
| 87 | 87 | $this->getParameterHolderOrCreate($namespace)->addParameters($parameters); |
| 88 | - } |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public function getParameters($namespace){ |
| 104 | 104 | $this->getParameterHolderOrCreate($namespace)->getParameters(); |
| 105 | - } |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | 107 | |
| 108 | 108 | /** |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public function getParameter($namespace, $name){ |
| 115 | 115 | $this->getParameterHolderOrCreate($namespace)->getParameter($name); |
| 116 | - } |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | 118 | |
| 119 | 119 | /** |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | public function setParameter($namespace, $name, $value){ |
| 127 | 127 | $this->getParameterHolderOrCreate($namespace)->setParameters($parameters); |
| 128 | - } |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | public function hasParameter($namespace, $name){ |
| 138 | 138 | $this->getParameterHolderOrCreate($namespace)->hasParameter($name); |
| 139 | - } |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | 141 | |
| 142 | 142 | /** |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | */ |
| 148 | 148 | public function deleteParameter($namespace, $name){ |
| 149 | 149 | $this->getParameterHolderOrCreate($namespace)->setParameters($parameters); |
| 150 | - } |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | 152 | |
| 153 | 153 | /** |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | public function setParameterHolder($namespace, \PEIP\INF\Data\ParameterHolder $holder){ |
| 168 | 168 | $this->stores[$namespace] = $holder; |
| 169 | - } |
|
| 169 | + } |
|
| 170 | 170 | |
| 171 | 171 | |
| 172 | 172 | /** |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | */ |
| 184 | 184 | public function getParameterHolder($namespace){ |
| 185 | 185 | return $this->stores[$namespace]; |
| 186 | - } |
|
| 186 | + } |
|
| 187 | 187 | |
| 188 | 188 | |
| 189 | 189 | /** |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | */ |
| 201 | 201 | public function hasParameterHolder($namespace){ |
| 202 | 202 | return array_key_exists($namespace, $this->stores); |
| 203 | - } |
|
| 203 | + } |
|
| 204 | 204 | |
| 205 | 205 | |
| 206 | 206 | /** |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | */ |
| 218 | 218 | public function deleteParameterHolder($namespace){ |
| 219 | 219 | unset($this->stores[$namespace]); |
| 220 | - } |
|
| 220 | + } |
|
| 221 | 221 | |
| 222 | 222 | |
| 223 | 223 | |
@@ -47,18 +47,18 @@ |
||
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * Builds and modifies an arbitrary service/object instance from a config-obect. |
|
| 52 | - * |
|
| 53 | - * @see XMLContext::doBuild |
|
| 54 | - * @see XMLContext::modifyService |
|
| 55 | - * @implements \PEIP\INF\Context\Context |
|
| 56 | - * @access public |
|
| 57 | - * @param object $config configuration object to build a service instance from. |
|
| 58 | - * @param array $arguments arguments for the service constructor |
|
| 59 | - * @param string $defaultClass class to create instance for if none is set in config |
|
| 60 | - * @return object build and modified srvice instance |
|
| 61 | - */ |
|
| 50 | + /** |
|
| 51 | + * Builds and modifies an arbitrary service/object instance from a config-obect. |
|
| 52 | + * |
|
| 53 | + * @see XMLContext::doBuild |
|
| 54 | + * @see XMLContext::modifyService |
|
| 55 | + * @implements \PEIP\INF\Context\Context |
|
| 56 | + * @access public |
|
| 57 | + * @param object $config configuration object to build a service instance from. |
|
| 58 | + * @param array $arguments arguments for the service constructor |
|
| 59 | + * @param string $defaultClass class to create instance for if none is set in config |
|
| 60 | + * @return object build and modified srvice instance |
|
| 61 | + */ |
|
| 62 | 62 | public function buildAndModify($config, $arguments, $defaultClass = false){ |
| 63 | 63 | return ServiceFactory::buildAndModify($config, $arguments, $defaultClass); |
| 64 | 64 | } |