@@ -56,24 +56,24 @@ discard block |
||
56 | 56 | * @param string $string the configuration string |
57 | 57 | * @return |
58 | 58 | */ |
59 | - public function __construct($string){ |
|
59 | + public function __construct($string) { |
|
60 | 60 | $this->initNodeBuilders(); |
61 | 61 | $reader = new XMLContextReader($string); |
62 | 62 | |
63 | 63 | |
64 | 64 | $serviceActivator = new HeaderServiceActivator(array($this, 'addConfig'), 'NODE'); |
65 | 65 | |
66 | - $reader->connect('read_node', $serviceActivator); |
|
66 | + $reader->connect('read_node', $serviceActivator); |
|
67 | 67 | $reader->read(); |
68 | 68 | |
69 | 69 | |
70 | 70 | } |
71 | 71 | |
72 | - public function addConfig($config){ |
|
72 | + public function addConfig($config) { |
|
73 | 73 | return $this->getServiceProvider()->addConfig($config); |
74 | 74 | } |
75 | 75 | |
76 | - public function handleReadConfig(\PEIP\INF\Event\Event $event){ |
|
76 | + public function handleReadConfig(\PEIP\INF\Event\Event $event) { |
|
77 | 77 | $this->addConfig($event->getHeader('NODE')); |
78 | 78 | } |
79 | 79 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @return XMLContext the context instance |
86 | 86 | * @throws RuntimeException |
87 | 87 | */ |
88 | - public static function createFromString($string){ |
|
88 | + public static function createFromString($string) { |
|
89 | 89 | return new XMLContext($string); |
90 | 90 | } |
91 | 91 | |
@@ -97,10 +97,10 @@ discard block |
||
97 | 97 | * @return XMLContext the context instance |
98 | 98 | * @throws RuntimeException |
99 | 99 | */ |
100 | - public static function createFromFile($file){ |
|
101 | - if(file_exists($file)){ |
|
100 | + public static function createFromFile($file) { |
|
101 | + if (file_exists($file)) { |
|
102 | 102 | return self::createFromString(file_get_contents($file)); |
103 | - }else{ |
|
103 | + }else { |
|
104 | 104 | throw new \RuntimeException('Cannot open file "'.$file.'".'); |
105 | 105 | } |
106 | 106 | } |
@@ -111,15 +111,15 @@ discard block |
||
111 | 111 | * @access protected |
112 | 112 | * @return void |
113 | 113 | */ |
114 | - protected function init(){ |
|
114 | + protected function init() { |
|
115 | 115 | $xml = $this->simpleXML; |
116 | 116 | $this->channelRegistry = ChannelRegistry::getInstance(); |
117 | 117 | // register this context as a service if id is set. |
118 | - if($xml['id']){ |
|
118 | + if ($xml['id']) { |
|
119 | 119 | $this->services[(string)$xml['id']] = $this; |
120 | 120 | } |
121 | 121 | // build services |
122 | - foreach($xml->children() as $entry){ |
|
122 | + foreach ($xml->children() as $entry) { |
|
123 | 123 | $this->buildNode($entry); |
124 | 124 | } |
125 | 125 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | * @param string $nodeName the name of the node |
133 | 133 | * @param callable $callable a callable which creates instances for node-name |
134 | 134 | */ |
135 | - public function registerNodeBuilder($nodeName, $callable){ |
|
135 | + public function registerNodeBuilder($nodeName, $callable) { |
|
136 | 136 | return $this->getServiceProvider()->registerNodeBuilder($nodeName, $callable); |
137 | 137 | } |
138 | 138 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @access public |
144 | 144 | * @param \PEIP\INF\Context\Context_Plugin $plugin a plugin instance |
145 | 145 | */ |
146 | - public function addPlugin(\PEIP\INF\Context\ContextPlugin $plugin){ |
|
146 | + public function addPlugin(\PEIP\INF\Context\ContextPlugin $plugin) { |
|
147 | 147 | $plugin->init($this); |
148 | 148 | } |
149 | 149 | |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * @param object $config configuration object for the plugin |
155 | 155 | * @return |
156 | 156 | */ |
157 | - public function createPlugin($config){ |
|
157 | + public function createPlugin($config) { |
|
158 | 158 | $plugin = $this->createService($config); |
159 | 159 | $this->addPlugin($plugin); |
160 | 160 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | * @access public |
176 | 176 | * @param XMLContext $config the config to include |
177 | 177 | */ |
178 | - public function includeContext(XMLContext $context){ |
|
178 | + public function includeContext(XMLContext $context) { |
|
179 | 179 | $this->services = array_merge($this->services, $context->getServices()); |
180 | 180 | } |
181 | 181 | |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | * @access public |
187 | 187 | * @param XMLContext $context the config to include |
188 | 188 | */ |
189 | - public function includeContextFromFile($filePath){ |
|
190 | - if(file_exists($filePath)){ |
|
189 | + public function includeContextFromFile($filePath) { |
|
190 | + if (file_exists($filePath)) { |
|
191 | 191 | $this->includeContextFromString(file_get_contents($filePath)); |
192 | 192 | } |
193 | 193 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * @access public |
200 | 200 | * @param string $configString the config to include |
201 | 201 | */ |
202 | - public function includeContextFromString($configString){ |
|
202 | + public function includeContextFromString($configString) { |
|
203 | 203 | $context = new XMLContext($configString); |
204 | 204 | $this->includeContext($context); |
205 | 205 | } |
@@ -211,14 +211,14 @@ discard block |
||
211 | 211 | * @access protected |
212 | 212 | * @param object $config the configuration for the context |
213 | 213 | */ |
214 | - protected function createContext($config){ |
|
215 | - if((string)$config['file'] != ''){ |
|
214 | + protected function createContext($config) { |
|
215 | + if ((string)$config['file'] != '') { |
|
216 | 216 | $this->includeContextFromFile((string)$config['file']); |
217 | 217 | } |
218 | 218 | } |
219 | 219 | |
220 | 220 | |
221 | - public function getServiceProvider(){ |
|
221 | + public function getServiceProvider() { |
|
222 | 222 | return isset($this->serviceProvider) |
223 | 223 | ? $this->serviceProvider |
224 | 224 | : $this->serviceProvider = new ServiceProvider(); |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * @see XMLContext::includeContext |
235 | 235 | * @access protected |
236 | 236 | */ |
237 | - protected function initNodeBuilders(){ |
|
237 | + protected function initNodeBuilders() { |
|
238 | 238 | $builders = array( |
239 | 239 | 'include' => 'createContext', |
240 | 240 | 'plugin' => 'createPlugin', |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | ); |
253 | 253 | $plugin = new BasePlugin(); |
254 | 254 | $this->addPlugin($plugin); return; |
255 | - foreach($builders as $nodeName => $method){ |
|
255 | + foreach ($builders as $nodeName => $method) { |
|
256 | 256 | $this->registerNodeBuilder($nodeName, array($this, $method)); |
257 | 257 | } |
258 | 258 | } |
@@ -266,10 +266,10 @@ discard block |
||
266 | 266 | * @param object $node configuration-node |
267 | 267 | * @return void |
268 | 268 | */ |
269 | - protected function buildNode($node){ |
|
269 | + protected function buildNode($node) { |
|
270 | 270 | $nodeName = $node->getName(); |
271 | 271 | // call the builder method registered for the node. |
272 | - if(array_key_exists($nodeName, $this->nodeBuilders)){ |
|
272 | + if (array_key_exists($nodeName, $this->nodeBuilders)) { |
|
273 | 273 | call_user_func($this->nodeBuilders[$nodeName], $node); |
274 | 274 | } |
275 | 275 | } |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | * @param string $channelName the name/id of the channel to return |
289 | 289 | * @return \PEIP\INF\Channel\Channel |
290 | 290 | */ |
291 | - public function resolveChannelName($channelName){ |
|
291 | + public function resolveChannelName($channelName) { |
|
292 | 292 | return $this->channelRegistry->get($channelName); |
293 | 293 | } |
294 | 294 | |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * @param mixed $id the id for the service |
301 | 301 | * @return object the service instance if found |
302 | 302 | */ |
303 | - public function getService($id){ |
|
303 | + public function getService($id) { |
|
304 | 304 | return $this->getServiceProvider()->provideService($id); |
305 | 305 | } |
306 | 306 | |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | * @access public |
311 | 311 | * @return array registered services |
312 | 312 | */ |
313 | - public function getServices(){ |
|
313 | + public function getServices() { |
|
314 | 314 | return $this->getServiceProvider()->getServices(); |
315 | 315 | } |
316 | 316 | |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | * @param mixed $id the id for the service |
322 | 322 | * @return boolean wether service is registered |
323 | 323 | */ |
324 | - public function hasService($id){ |
|
324 | + public function hasService($id) { |
|
325 | 325 | return isset($this->services[$id]); |
326 | 326 | } |
327 | 327 | |
@@ -335,9 +335,9 @@ discard block |
||
335 | 335 | * @return object the service instance if found |
336 | 336 | * |
337 | 337 | */ |
338 | - protected function requestService($id){ |
|
338 | + protected function requestService($id) { |
|
339 | 339 | $service = $this->getService($id); |
340 | - if($service === NULL){ |
|
340 | + if ($service === NULL) { |
|
341 | 341 | throw new \RuntimeException('Service "'.$id.'" not found.'); |
342 | 342 | } |
343 | 343 | return $service; |
@@ -351,9 +351,9 @@ discard block |
||
351 | 351 | * @param object $config |
352 | 352 | * @return object the initialized service instance |
353 | 353 | */ |
354 | - protected function initService($config){ |
|
354 | + protected function initService($config) { |
|
355 | 355 | $id = trim((string)$config['id']); |
356 | - if($id != ''){ |
|
356 | + if ($id != '') { |
|
357 | 357 | return $this->services[$id] = $this->createService($config); |
358 | 358 | } |
359 | 359 | } |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | * @param $config |
366 | 366 | * @return object the initialized service instance |
367 | 367 | */ |
368 | - public function createService($config){ |
|
368 | + public function createService($config) { |
|
369 | 369 | return ServiceFactory::createService($config); |
370 | 370 | } |
371 | 371 | |
@@ -382,29 +382,29 @@ discard block |
||
382 | 382 | * @param object $config configuration to get the modification instructions from. |
383 | 383 | * @return object the modificated service |
384 | 384 | */ |
385 | - protected function modifyService($service, $config){ |
|
385 | + protected function modifyService($service, $config) { |
|
386 | 386 | $reflection = GenericBuilder::getInstance(get_class($service))->getReflectionClass(); |
387 | 387 | // set instance properties |
388 | - if($config->property){ |
|
389 | - foreach($config->property as $property){ |
|
388 | + if ($config->property) { |
|
389 | + foreach ($config->property as $property) { |
|
390 | 390 | $arg = $this->buildArg($property); |
391 | - if($arg){ |
|
391 | + if ($arg) { |
|
392 | 392 | $setter = self::getSetter($property); |
393 | - if($setter && self::hasPublicProperty($service, 'Method', $setter)){ |
|
393 | + if ($setter && self::hasPublicProperty($service, 'Method', $setter)) { |
|
394 | 394 | $service->{$setter}($arg); |
395 | - }elseif(in_array($property, self::hasPublicProperty($service, 'Property', $setter))){ |
|
395 | + }elseif (in_array($property, self::hasPublicProperty($service, 'Property', $setter))) { |
|
396 | 396 | $service->$setter = $arg; |
397 | 397 | } |
398 | 398 | } |
399 | 399 | } |
400 | 400 | } |
401 | 401 | // call instance methods |
402 | - if($config->action){ |
|
403 | - foreach($config->action as $action){ |
|
402 | + if ($config->action) { |
|
403 | + foreach ($config->action as $action) { |
|
404 | 404 | $method = (string)$action['method'] != '' ? (string)$action['method'] : NULL; |
405 | - if($method && self::hasPublicProperty($service, 'Method', $method)){ |
|
405 | + if ($method && self::hasPublicProperty($service, 'Method', $method)) { |
|
406 | 406 | $args = array(); |
407 | - foreach($action->children() as $argument){ |
|
407 | + foreach ($action->children() as $argument) { |
|
408 | 408 | $args[] = $this->buildArg($argument); |
409 | 409 | } |
410 | 410 | call_user_func_array(array($service, (string)$action['method']), $args); |
@@ -412,9 +412,9 @@ discard block |
||
412 | 412 | } |
413 | 413 | } |
414 | 414 | // register instance listeners |
415 | - if($service instanceof \PEIP\INF\Event\Connectable){ |
|
416 | - if($config->listener){ |
|
417 | - foreach($config->listener as $listenerConf){ |
|
415 | + if ($service instanceof \PEIP\INF\Event\Connectable) { |
|
416 | + if ($config->listener) { |
|
417 | + foreach ($config->listener as $listenerConf) { |
|
418 | 418 | $event = (string)$listenerConf['event']; |
419 | 419 | $listener = $this->provideService($listenerConf); |
420 | 420 | $service->connect($event, $listener); |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | * @param mixed $id the id ofthe gateway |
434 | 434 | * @return object the gateway instance |
435 | 435 | */ |
436 | - public function getGateway($id){ |
|
436 | + public function getGateway($id) { |
|
437 | 437 | return $this->getServiceProvider()->provideService($id); |
438 | 438 | } |
439 | 439 | |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | * @param object $config configuration object for the pollable channel. |
446 | 446 | * @return \PEIP\INF\Channel\Channel the created pollable channel instance |
447 | 447 | */ |
448 | - public function createChannel($config){ |
|
448 | + public function createChannel($config) { |
|
449 | 449 | return $this->doCreateChannel($config, 'PollableChannel'); |
450 | 450 | } |
451 | 451 | |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | * @param object $config configuration object for the subscribable channel. |
458 | 458 | * @return \PEIP\INF\Channel\Channel the created subscribable channel instance |
459 | 459 | */ |
460 | - public function createSubscribableChannel($config){ |
|
460 | + public function createSubscribableChannel($config) { |
|
461 | 461 | return $this->doCreateChannel($config, 'PublishSubscribeChannel'); |
462 | 462 | } |
463 | 463 | |
@@ -470,9 +470,9 @@ discard block |
||
470 | 470 | * @param $additionalArguments additional arguments for the channel constructor (without first arg = id) |
471 | 471 | * @return \PEIP\INF\Channel\Channel the created channel instance |
472 | 472 | */ |
473 | - public function doCreateChannel($config, $defaultChannelClass, array $additionalArguments = array()){ |
|
473 | + public function doCreateChannel($config, $defaultChannelClass, array $additionalArguments = array()) { |
|
474 | 474 | $id = (string)$config['id']; |
475 | - if($id != ''){ |
|
475 | + if ($id != '') { |
|
476 | 476 | array_unshift($additionalArguments, $id); |
477 | 477 | $channel = $this->buildAndModify($config, $additionalArguments, $defaultChannelClass); |
478 | 478 | $this->channelRegistry->register($channel); |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | * @param string $defaultClass the class to use if none is set in config. |
490 | 490 | * @return object the gateway instance |
491 | 491 | */ |
492 | - public function createGateway($config, $defaultClass = false){ |
|
492 | + public function createGateway($config, $defaultClass = false) { |
|
493 | 493 | $args = array( |
494 | 494 | $this->getRequestChannel($config), |
495 | 495 | $this->getReplyChannel($config) |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | * @param string $defaultClass the class to use if none is set in config. |
514 | 514 | * @return object the router instance |
515 | 515 | */ |
516 | - public function createRouter($config, $defaultClass = false){ |
|
516 | + public function createRouter($config, $defaultClass = false) { |
|
517 | 517 | $resolver = $config['channel_resolver'] ? (string)$config['channel_resolver'] : $this->channelRegistry; |
518 | 518 | return $this->buildAndModify($config, array( |
519 | 519 | $resolver, |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | * @param object $config configuration object for the splitter. |
531 | 531 | * @return object the splitter instance |
532 | 532 | */ |
533 | - public function createSplitter($config){ |
|
533 | + public function createSplitter($config) { |
|
534 | 534 | return $this->createReplyMessageHandler($config); |
535 | 535 | } |
536 | 536 | |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | * @param object $config configuration object for the transformer. |
544 | 544 | * @return object the transformer instance |
545 | 545 | */ |
546 | - public function createTransformer($config){ |
|
546 | + public function createTransformer($config) { |
|
547 | 547 | return $this->createReplyMessageHandler($config); |
548 | 548 | } |
549 | 549 | |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | * @param object $config configuration object for the aggregator. |
557 | 557 | * @return object the aggregator instance |
558 | 558 | */ |
559 | - public function createAggregator($config){ |
|
559 | + public function createAggregator($config) { |
|
560 | 560 | return $this->createReplyMessageHandler($config); |
561 | 561 | } |
562 | 562 | |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | * @param object $config configuration object for the wiretap. |
570 | 570 | * @return object the wiretap instance |
571 | 571 | */ |
572 | - public function createWiretap($config){ |
|
572 | + public function createWiretap($config) { |
|
573 | 573 | return $this->createReplyMessageHandler($config, 'Wiretap'); |
574 | 574 | } |
575 | 575 | |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | * @param string $defaultClass the class to use if none is set in config. |
583 | 583 | * @return object the reply-message-handler instance |
584 | 584 | */ |
585 | - public function createReplyMessageHandler($config, $defaultClass = false){ |
|
585 | + public function createReplyMessageHandler($config, $defaultClass = false) { |
|
586 | 586 | return $this->buildAndModify($config, $this->getReplyHandlerArguments($config), $defaultClass); |
587 | 587 | } |
588 | 588 | |
@@ -595,12 +595,12 @@ discard block |
||
595 | 595 | * @param string $defaultClass the class to use if none is set in config. |
596 | 596 | * @return object the service-activator instance |
597 | 597 | */ |
598 | - public function createServiceActivator($config, $defaultClass = false){ |
|
598 | + public function createServiceActivator($config, $defaultClass = false) { |
|
599 | 599 | $method = (string)$config['method']; |
600 | 600 | $service = $this->getService((string)$config['ref']); |
601 | - if($method && $service){ |
|
601 | + if ($method && $service) { |
|
602 | 602 | $args = $this->getReplyHandlerArguments($config); |
603 | - array_unshift($args,array( |
|
603 | + array_unshift($args, array( |
|
604 | 604 | $service, |
605 | 605 | $method |
606 | 606 | )); |
@@ -621,11 +621,11 @@ discard block |
||
621 | 621 | * @param object $config configuration object for the service. |
622 | 622 | * @return |
623 | 623 | */ |
624 | - protected function provideService($config){ |
|
624 | + protected function provideService($config) { |
|
625 | 625 | $ref = trim((string)$config['ref']); |
626 | - if($ref != ''){ |
|
626 | + if ($ref != '') { |
|
627 | 627 | $service = $this->getService($ref); |
628 | - }else{ |
|
628 | + }else { |
|
629 | 629 | $service = $this->createService($config); |
630 | 630 | } |
631 | 631 | return $service; |
@@ -642,10 +642,10 @@ discard block |
||
642 | 642 | * @param object $config configuration object for the setter-method. |
643 | 643 | * @return string camel-cased |
644 | 644 | */ |
645 | - protected static function getSetter($config){ |
|
646 | - if($config['setter']){ |
|
645 | + protected static function getSetter($config) { |
|
646 | + if ($config['setter']) { |
|
647 | 647 | $setter = (string)$config['setter']; |
648 | - }elseif($config['name']){ |
|
648 | + }elseif ($config['name']) { |
|
649 | 649 | $setter = 'set'.ucfirst((string)$config['name']); |
650 | 650 | } |
651 | 651 | return $setter; |
@@ -658,29 +658,29 @@ discard block |
||
658 | 658 | * @param object $config configuration object to create argument from. |
659 | 659 | * @return mixed build argument |
660 | 660 | */ |
661 | - protected function buildArg($config){ |
|
662 | - if(trim((string)$config['value']) != ''){ |
|
661 | + protected function buildArg($config) { |
|
662 | + if (trim((string)$config['value']) != '') { |
|
663 | 663 | $arg = (string)$config['value']; |
664 | - }elseif($config->getName() == 'value'){ |
|
664 | + }elseif ($config->getName() == 'value') { |
|
665 | 665 | $arg = (string)$config; |
666 | - }elseif($config->getName() == 'list'){ |
|
666 | + }elseif ($config->getName() == 'list') { |
|
667 | 667 | $arg = array(); |
668 | - foreach($config->children() as $entry){ |
|
669 | - if($entry->getName() == 'value'){ |
|
670 | - if($entry['key']){ |
|
668 | + foreach ($config->children() as $entry) { |
|
669 | + if ($entry->getName() == 'value') { |
|
670 | + if ($entry['key']) { |
|
671 | 671 | $arg[(string)$entry['key']] = (string)$entry; |
672 | - }else{ |
|
672 | + }else { |
|
673 | 673 | $arg[] = (string)$entry; |
674 | 674 | } |
675 | - }elseif($entry->getName() == 'service'){ |
|
675 | + }elseif ($entry->getName() == 'service') { |
|
676 | 676 | $arg[] = $this->provideService($entry); |
677 | 677 | } |
678 | 678 | } |
679 | - }elseif($config->getName() == 'service'){ |
|
679 | + }elseif ($config->getName() == 'service') { |
|
680 | 680 | $arg = $this->provideService($config); |
681 | - }elseif($config->list){ |
|
681 | + }elseif ($config->list) { |
|
682 | 682 | $arg = $this->buildArg($config->list); |
683 | - }elseif($config->service){ |
|
683 | + }elseif ($config->service) { |
|
684 | 684 | $arg = $this->buildArg($config->service); |
685 | 685 | } |
686 | 686 | return $arg; |
@@ -694,12 +694,12 @@ discard block |
||
694 | 694 | * @param object $config configuration object to create arguments from. |
695 | 695 | * @return mixed build arguments |
696 | 696 | */ |
697 | - protected function getReplyHandlerArguments($config){ |
|
697 | + protected function getReplyHandlerArguments($config) { |
|
698 | 698 | $args = array( |
699 | 699 | $this->doGetChannel('input', $config), |
700 | 700 | $this->doGetChannel('output', $config) |
701 | 701 | ); |
702 | - if($args[0] == NULL){ |
|
702 | + if ($args[0] == NULL) { |
|
703 | 703 | throw new \RuntimeException('Could not receive input channel.'); |
704 | 704 | } |
705 | 705 | return $args; |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | * @param object $config configuration object to return request-channel from. |
715 | 715 | * @return \PEIP\INF\Channel\Channel request-channel |
716 | 716 | */ |
717 | - protected function getRequestChannel($config){ |
|
717 | + protected function getRequestChannel($config) { |
|
718 | 718 | return $this->doGetChannel('request', $config); |
719 | 719 | } |
720 | 720 | |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | * @param object $config configuration object to return reply-channel from. |
728 | 728 | * @return \PEIP\INF\Channel\Channel reply-channel |
729 | 729 | */ |
730 | - protected function getReplyChannel($config){ |
|
730 | + protected function getReplyChannel($config) { |
|
731 | 731 | return $this->doGetChannel('reply', $config); |
732 | 732 | } |
733 | 733 | |
@@ -740,15 +740,15 @@ discard block |
||
740 | 740 | * @param object $config configuration object to return channel from. |
741 | 741 | * @return \PEIP\INF\Channel\Channel reply-channel |
742 | 742 | */ |
743 | - public function doGetChannel($type, $config){ |
|
743 | + public function doGetChannel($type, $config) { |
|
744 | 744 | $channelName = $config[$type."_channel"] |
745 | 745 | ? $config[$type."_channel"] |
746 | 746 | : $config["default_".$type."_channel"]; |
747 | 747 | return $this->serviceProvider->provideService(trim((string)$channelName)); |
748 | - $channel = $this->services[trim((string)$channelName)]; |
|
749 | - if($channel instanceof \PEIP\INF\Channel\Channel){ |
|
748 | + $channel = $this->services[trim((string)$channelName)]; |
|
749 | + if ($channel instanceof \PEIP\INF\Channel\Channel) { |
|
750 | 750 | return $channel; |
751 | - }else{ |
|
751 | + }else { |
|
752 | 752 | return NULL; |
753 | 753 | } |
754 | 754 | } |
@@ -766,31 +766,31 @@ discard block |
||
766 | 766 | * @param string $defaultClass class to create instance for if none is set in config |
767 | 767 | * @return object build and modified srvice instance |
768 | 768 | */ |
769 | - public function buildAndModify($config, $arguments, $defaultClass = false){ |
|
770 | - if("" != (string)$config["class"] || $defaultClass){ |
|
769 | + public function buildAndModify($config, $arguments, $defaultClass = false) { |
|
770 | + if ("" != (string)$config["class"] || $defaultClass) { |
|
771 | 771 | $service = ServiceFactory::doBuild($config, $arguments, $defaultClass); |
772 | - }elseif($config["ref"]){ |
|
772 | + }elseif ($config["ref"]) { |
|
773 | 773 | $service = $this->getService((string)$config['ref']); |
774 | - }else{ |
|
774 | + }else { |
|
775 | 775 | throw new \RuntimeException('Could not create Service. no class or reference given.'); |
776 | 776 | } |
777 | - if($config["ref_property"]){ |
|
777 | + if ($config["ref_property"]) { |
|
778 | 778 | $service = $service->{(string)$config["ref_property"]}; |
779 | - }elseif($config["ref_method"]){ |
|
779 | + }elseif ($config["ref_method"]) { |
|
780 | 780 | $args = array(); |
781 | - if($config->argument){ |
|
782 | - foreach($config->argument as $arg){ |
|
781 | + if ($config->argument) { |
|
782 | + foreach ($config->argument as $arg) { |
|
783 | 783 | $args[] = $this->buildArg($arg); |
784 | 784 | } |
785 | 785 | } |
786 | 786 | $service = call_user_func_array(array($service, (string)$config["ref_method"]), $args); |
787 | 787 | } |
788 | - if(!is_object($service)){ |
|
788 | + if (!is_object($service)) { |
|
789 | 789 | throw new \RuntimeException('Could not create Service.'); |
790 | 790 | } |
791 | 791 | $service = $this->modifyService($service, $config); |
792 | 792 | $id = trim((string)$config['id']); |
793 | - if($service && $id != ''){ |
|
793 | + if ($service && $id != '') { |
|
794 | 794 | $this->services[$id] = $service; |
795 | 795 | } |
796 | 796 | return $service; |
@@ -806,21 +806,21 @@ discard block |
||
806 | 806 | * @param string $defaultClass class to create instance for if none is set in config |
807 | 807 | * @return object build and modified srvice instance |
808 | 808 | */ |
809 | - protected static function doBuild($config, $arguments, $defaultClass = false){ |
|
809 | + protected static function doBuild($config, $arguments, $defaultClass = false) { |
|
810 | 810 | $cls = $config["class"] ? trim((string)$config["class"]) : (string)$defaultClass; |
811 | - if($cls != ''){ |
|
811 | + if ($cls != '') { |
|
812 | 812 | try { |
813 | 813 | $constructor = (string)$config["constructor"]; |
814 | - if($constructor != ''){ |
|
814 | + if ($constructor != '') { |
|
815 | 815 | $service = call_user_func_array(array($cls, $constructor), $arguments); |
816 | - }else{ |
|
816 | + }else { |
|
817 | 817 | $service = self::build($cls, $arguments); |
818 | 818 | } |
819 | - }catch(\Exception $e){ |
|
819 | + } catch (\Exception $e) { |
|
820 | 820 | throw new \RuntimeException('Could not create Service "'.$cls.'" -> '.$e->getMessage()); |
821 | 821 | } |
822 | 822 | } |
823 | - if(is_object($service)){ |
|
823 | + if (is_object($service)) { |
|
824 | 824 | return $service; |
825 | 825 | } |
826 | 826 | throw new \RuntimeException('Could not create Service "'.$cls.'". Class does not exist.'); |
@@ -836,13 +836,13 @@ discard block |
||
836 | 836 | * @param array $arguments arguments for the constructor |
837 | 837 | * @return object build and modified srvice instance |
838 | 838 | */ |
839 | - protected static function build($className, $arguments){ |
|
839 | + protected static function build($className, $arguments) { |
|
840 | 840 | return GenericBuilder::getInstance($className)->build($arguments); |
841 | 841 | } |
842 | 842 | |
843 | - protected static function hasPublicProperty($service, $type, $name){ |
|
843 | + protected static function hasPublicProperty($service, $type, $name) { |
|
844 | 844 | $reflection = GenericBuilder::getInstance(get_class($service))->getReflectionClass(); |
845 | - if($reflection->{'has'.$type}($name) && $reflection->{'get'.$type}($name)->isPublic()){ |
|
845 | + if ($reflection->{'has'.$type}($name) && $reflection->{'get'.$type}($name)->isPublic()) { |
|
846 | 846 | return true; |
847 | 847 | } |
848 | 848 | return false; |