@@ -42,7 +42,6 @@ |
||
| 42 | 42 | * @static |
| 43 | 43 | * @access public |
| 44 | 44 | * @implements \PEIP\INF\Base\Buildable |
| 45 | - * @param string $name the name of the header |
|
| 46 | 45 | * @return boolean wether the header is set |
| 47 | 46 | */ |
| 48 | 47 | public static function build(array $arguments = array()){ |
@@ -27,11 +27,11 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | const CONTENT_CAST_TYPE = 'string'; |
| 29 | 29 | |
| 30 | - public function __toString(){ |
|
| 30 | + public function __toString() { |
|
| 31 | 31 | return (string)$this->getContent(); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - public function getContent(){ |
|
| 34 | + public function getContent() { |
|
| 35 | 35 | return (string)parent::getContent(); |
| 36 | 36 | } |
| 37 | 37 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * @param string $name the name of the header |
| 46 | 46 | * @return boolean wether the header is set |
| 47 | 47 | */ |
| 48 | - public static function build(array $arguments = array()){ |
|
| 48 | + public static function build(array $arguments = array()) { |
|
| 49 | 49 | return GenericBuilder::getInstance(__CLASS__)->build($arguments); |
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | \ No newline at end of file |
@@ -64,7 +64,6 @@ |
||
| 64 | 64 | * @static |
| 65 | 65 | * @access public |
| 66 | 66 | * @implements \PEIP\INF\Base\Buildable |
| 67 | - * @param string $name the name of the header |
|
| 68 | 67 | * @return boolean wether the header is set |
| 69 | 68 | */ |
| 70 | 69 | public static function build(array $arguments = array()){ |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @param $title |
| 35 | 35 | * @return |
| 36 | 36 | */ |
| 37 | - public function __construct($content, $title){ |
|
| 37 | + public function __construct($content, $title) { |
|
| 38 | 38 | $this->setContent((string)$content); |
| 39 | 39 | } |
| 40 | 40 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | * @param $title |
| 45 | 45 | * @return |
| 46 | 46 | */ |
| 47 | - public function setTitle($title){ |
|
| 47 | + public function setTitle($title) { |
|
| 48 | 48 | $this->title = (string)$title; |
| 49 | 49 | } |
| 50 | 50 | |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * @access public |
| 54 | 54 | * @return |
| 55 | 55 | */ |
| 56 | - public function getTitle(){ |
|
| 56 | + public function getTitle() { |
|
| 57 | 57 | return $this->title; |
| 58 | 58 | } |
| 59 | 59 | |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * @param string $name the name of the header |
| 68 | 68 | * @return boolean wether the header is set |
| 69 | 69 | */ |
| 70 | - public static function build(array $arguments = array()){ |
|
| 70 | + public static function build(array $arguments = array()) { |
|
| 71 | 71 | return GenericBuilder::getInstance('\PEIP\Message\StringMessage')->build($arguments); |
| 72 | 72 | } |
| 73 | 73 | |
@@ -42,7 +42,7 @@ |
||
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | 44 | * @access public |
| 45 | - * @param $eventName |
|
| 45 | + * @param string $eventName |
|
| 46 | 46 | * @return |
| 47 | 47 | */ |
| 48 | 48 | public function setEventName($eventName){ |
@@ -31,10 +31,10 @@ discard block |
||
| 31 | 31 | * @param $inputChannel |
| 32 | 32 | * @return |
| 33 | 33 | */ |
| 34 | - public function setInputChannel(\PEIP\INF\Channel\Channel $inputChannel){ |
|
| 35 | - if(isset($this->eventName)){ |
|
| 34 | + public function setInputChannel(\PEIP\INF\Channel\Channel $inputChannel) { |
|
| 35 | + if (isset($this->eventName)) { |
|
| 36 | 36 | $this->connectChannel($inputChannel); |
| 37 | - }else{ |
|
| 37 | + }else { |
|
| 38 | 38 | $this->inputChannel = $inputChannel; |
| 39 | 39 | } |
| 40 | 40 | } |
@@ -45,10 +45,10 @@ discard block |
||
| 45 | 45 | * @param $eventName |
| 46 | 46 | * @return |
| 47 | 47 | */ |
| 48 | - public function setEventName($eventName){ |
|
| 49 | - if(!isset($this->eventName)){ |
|
| 48 | + public function setEventName($eventName) { |
|
| 49 | + if (!isset($this->eventName)) { |
|
| 50 | 50 | $this->eventName = $eventName; |
| 51 | - if($this->inputChannel){ |
|
| 51 | + if ($this->inputChannel) { |
|
| 52 | 52 | $this->inputChannel->connect($this->eventName, $this); |
| 53 | 53 | } |
| 54 | 54 | } |
@@ -34,7 +34,7 @@ |
||
| 34 | 34 | public function setInputChannel(\PEIP\INF\Channel\Channel $inputChannel){ |
| 35 | 35 | if(isset($this->eventName)){ |
| 36 | 36 | $this->connectChannel($inputChannel); |
| 37 | - }else{ |
|
| 37 | + } else{ |
|
| 38 | 38 | $this->inputChannel = $inputChannel; |
| 39 | 39 | } |
| 40 | 40 | } |
@@ -184,7 +184,7 @@ |
||
| 184 | 184 | |
| 185 | 185 | /** |
| 186 | 186 | * @access protected |
| 187 | - * @param $commandName |
|
| 187 | + * @param string $commandName |
|
| 188 | 188 | * @param $callable |
| 189 | 189 | * @return |
| 190 | 190 | */ |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * @param $name |
| 61 | 61 | * @return |
| 62 | 62 | */ |
| 63 | - public function setName($name){ |
|
| 63 | + public function setName($name) { |
|
| 64 | 64 | $this->name = $name; |
| 65 | 65 | } |
| 66 | 66 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @access public |
| 70 | 70 | * @return |
| 71 | 71 | */ |
| 72 | - public function getName(){ |
|
| 72 | + public function getName() { |
|
| 73 | 73 | return $this->name; |
| 74 | 74 | } |
| 75 | 75 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * @param $timeout |
| 81 | 81 | * @return |
| 82 | 82 | */ |
| 83 | - public function send(\PEIP\INF\Message\Message $message, $timeout = -1){ |
|
| 83 | + public function send(\PEIP\INF\Message\Message $message, $timeout = -1) { |
|
| 84 | 84 | return $this->handle($message); |
| 85 | 85 | } |
| 86 | 86 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @param $message |
| 91 | 91 | * @return |
| 92 | 92 | */ |
| 93 | - protected function doSend(\PEIP\INF\Message\Message $message){ |
|
| 93 | + protected function doSend(\PEIP\INF\Message\Message $message) { |
|
| 94 | 94 | $this->doFireEvent(self::EVENT_PRE_PUBLISH, array(self::HEADER_MESSAGE=>$message)); |
| 95 | 95 | $this->getMessageDispatcher()->notify($message); |
| 96 | 96 | $this->doFireEvent(self::EVENT_POST_PUBLISH, array(self::HEADER_MESSAGE=>$message)); |
@@ -103,12 +103,12 @@ discard block |
||
| 103 | 103 | * @param $content |
| 104 | 104 | * @return |
| 105 | 105 | */ |
| 106 | - protected function replyMessage($message){ |
|
| 106 | + protected function replyMessage($message) { |
|
| 107 | 107 | $message = $this->ensureMessage($message); |
| 108 | 108 | //if(\PEIP\Util\Test::assertMessage($message)){ |
| 109 | - if($this->getOutputChannel()){ |
|
| 109 | + if ($this->getOutputChannel()) { |
|
| 110 | 110 | $this->getOutputChannel()->send($message); |
| 111 | - }else{ |
|
| 111 | + }else { |
|
| 112 | 112 | $this->doSend($message); |
| 113 | 113 | } |
| 114 | 114 | //} |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | * @param $message |
| 121 | 121 | * @return |
| 122 | 122 | */ |
| 123 | - protected function doReply(\PEIP\INF\Message\Message $message){ |
|
| 123 | + protected function doReply(\PEIP\INF\Message\Message $message) { |
|
| 124 | 124 | $this->replyMessage($message); |
| 125 | 125 | } |
| 126 | 126 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | * @param $handler |
| 131 | 131 | * @return |
| 132 | 132 | */ |
| 133 | - public function subscribe($handler){ |
|
| 133 | + public function subscribe($handler) { |
|
| 134 | 134 | Test::ensureHandler($handler); |
| 135 | 135 | $this->getMessageDispatcher()->connect($handler); |
| 136 | 136 | $this->doFireEvent(self::EVENT_SUBSCRIBE, array(self::HEADER_SUBSCRIBER=>$handler)); |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * @param $handler e |
| 143 | 143 | * @return |
| 144 | 144 | */ |
| 145 | - public function unsubscribe($handler){ |
|
| 145 | + public function unsubscribe($handler) { |
|
| 146 | 146 | Test::ensureHandler($handler); |
| 147 | 147 | $this->getMessageDispatcher()->disconnect($handler); |
| 148 | 148 | $this->doFireEvent( |
@@ -160,9 +160,9 @@ discard block |
||
| 160 | 160 | * @param $transferListeners |
| 161 | 161 | * @return |
| 162 | 162 | */ |
| 163 | - public function setMessageDispatcher(\PEIP\INF\Dispatcher\Dispatcher $dispatcher, $transferListeners = true){ |
|
| 164 | - if(isset($this->dispatcher) && $transferListeners){ |
|
| 165 | - foreach($this->dispatcher->getListeners() as $listener){ |
|
| 163 | + public function setMessageDispatcher(\PEIP\INF\Dispatcher\Dispatcher $dispatcher, $transferListeners = true) { |
|
| 164 | + if (isset($this->dispatcher) && $transferListeners) { |
|
| 165 | + foreach ($this->dispatcher->getListeners() as $listener) { |
|
| 166 | 166 | $dispatcher->connect($listener); |
| 167 | 167 | $this->dispatcher->disconnect($listener); |
| 168 | 168 | } |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | * @access public |
| 177 | 177 | * @return |
| 178 | 178 | */ |
| 179 | - public function getMessageDispatcher(){ |
|
| 179 | + public function getMessageDispatcher() { |
|
| 180 | 180 | $defaultDispatcher = self::DEFAULT_CLASS_MESSAGE_DISPATCHER; |
| 181 | 181 | return isset($this->dispatcher) ? $this->dispatcher : $this->dispatcher = new $defaultDispatcher; |
| 182 | 182 | } |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | * @param $callable |
| 189 | 189 | * @return |
| 190 | 190 | */ |
| 191 | - protected function registerCommand($commandName, $callable){ |
|
| 191 | + protected function registerCommand($commandName, $callable) { |
|
| 192 | 192 | $this->commands[$commandName] = $callable; |
| 193 | 193 | } |
| 194 | 194 | |
@@ -198,10 +198,10 @@ discard block |
||
| 198 | 198 | * @param $cmdMessage |
| 199 | 199 | * @return |
| 200 | 200 | */ |
| 201 | - public function command(\PEIP\INF\Message\Message $cmdMessage){ |
|
| 201 | + public function command(\PEIP\INF\Message\Message $cmdMessage) { |
|
| 202 | 202 | $this->doFireEvent(self::EVENT_PRE_COMMAND, array(self::HEADER_MESSAGE=>$cmdMessage)); |
| 203 | 203 | $commandName = trim((string)$cmdMessage->getHeader('COMMAND')); |
| 204 | - if($commandName != '' && array_key_exists($commandName, $this->commands)){ |
|
| 204 | + if ($commandName != '' && array_key_exists($commandName, $this->commands)) { |
|
| 205 | 205 | call_user_func($this->commands[$commandName], $cmdMessage->getContent()); |
| 206 | 206 | } |
| 207 | 207 | $this->doFireEvent(self::EVENT_POST_COMMAND, array(self::HEADER_MESSAGE=>$cmdMessage)); |
@@ -108,7 +108,7 @@ |
||
| 108 | 108 | //if(\PEIP\Util\Test::assertMessage($message)){ |
| 109 | 109 | if($this->getOutputChannel()){ |
| 110 | 110 | $this->getOutputChannel()->send($message); |
| 111 | - }else{ |
|
| 111 | + } else{ |
|
| 112 | 112 | $this->doSend($message); |
| 113 | 113 | } |
| 114 | 114 | //} |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | * |
| 214 | 214 | * @access protected |
| 215 | 215 | * @param object $config configuration object to create arguments from. |
| 216 | - * @return mixed build arguments |
|
| 216 | + * @return \PEIP\INF\Channel\Channel[] build arguments |
|
| 217 | 217 | */ |
| 218 | 218 | protected function getReplyHandlerArguments($config){ |
| 219 | 219 | $args = array( |
@@ -259,6 +259,7 @@ discard block |
||
| 259 | 259 | * @access protected |
| 260 | 260 | * @param string the configuration type ofthe channel (e.g.: 'reply', 'request') |
| 261 | 261 | * @param object $config configuration object to return channel from. |
| 262 | + * @param string $type |
|
| 262 | 263 | * @return \PEIP\INF\Channel\Channel reply-channel |
| 263 | 264 | */ |
| 264 | 265 | public function doGetChannel($type, $config){ |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * @param object $config configuration object for the pollable channel. |
| 43 | 43 | * @return \PEIP\INF\Channel\Channel the created pollable channel instance |
| 44 | 44 | */ |
| 45 | - public function createChannel($config){ |
|
| 45 | + public function createChannel($config) { |
|
| 46 | 46 | return $this->doCreateChannel($config, '\PEIP\Channel\PollableChannel'); |
| 47 | 47 | } |
| 48 | 48 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @param object $config configuration object for the subscribable channel. |
| 55 | 55 | * @return \PEIP\INF\Channel\Channel the created subscribable channel instance |
| 56 | 56 | */ |
| 57 | - public function createSubscribableChannel($config){ |
|
| 57 | + public function createSubscribableChannel($config) { |
|
| 58 | 58 | return $this->doCreateChannel($config, '\PEIP\Channel\PublishSubscribeChannel'); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -67,9 +67,9 @@ discard block |
||
| 67 | 67 | * @param $additionalArguments additional arguments for the channel constructor (without first arg = id) |
| 68 | 68 | * @return \PEIP\INF\Channel\Channel the created channel instance |
| 69 | 69 | */ |
| 70 | - public function doCreateChannel($config, $defaultChannelClass, array $additionalArguments = array()){ |
|
| 70 | + public function doCreateChannel($config, $defaultChannelClass, array $additionalArguments = array()) { |
|
| 71 | 71 | $id = (string)$config['id']; |
| 72 | - if($id != ''){ |
|
| 72 | + if ($id != '') { |
|
| 73 | 73 | array_unshift($additionalArguments, $id); |
| 74 | 74 | $channel = $this->buildAndModify($config, $additionalArguments, $defaultChannelClass); |
| 75 | 75 | //$this->channelRegistry->register($channel); |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | * @param string $defaultClass the class to use if none is set in config. |
| 88 | 88 | * @return object the gateway instance |
| 89 | 89 | */ |
| 90 | - public function createGateway($config, $defaultClass = false){ |
|
| 90 | + public function createGateway($config, $defaultClass = false) { |
|
| 91 | 91 | $args = array( |
| 92 | 92 | $this->getRequestChannel($config), |
| 93 | 93 | $this->getReplyChannel($config) |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * @param string $defaultClass the class to use if none is set in config. |
| 112 | 112 | * @return object the router instance |
| 113 | 113 | */ |
| 114 | - public function createRouter($config, $defaultClass = false){ |
|
| 114 | + public function createRouter($config, $defaultClass = false) { |
|
| 115 | 115 | $resolver = $config['channel_resolver'] ? (string)$config['channel_resolver'] : $this->channelRegistry; |
| 116 | 116 | return $this->buildAndModify($config, array( |
| 117 | 117 | $resolver, |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | * @param object $config configuration object for the splitter. |
| 129 | 129 | * @return object the splitter instance |
| 130 | 130 | */ |
| 131 | - public function createSplitter($config){ |
|
| 131 | + public function createSplitter($config) { |
|
| 132 | 132 | return $this->createReplyMessageHandler($config); |
| 133 | 133 | } |
| 134 | 134 | |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | * @param object $config configuration object for the transformer. |
| 142 | 142 | * @return object the transformer instance |
| 143 | 143 | */ |
| 144 | - public function createTransformer($config){ |
|
| 144 | + public function createTransformer($config) { |
|
| 145 | 145 | return $this->createReplyMessageHandler($config); |
| 146 | 146 | } |
| 147 | 147 | |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | * @param object $config configuration object for the aggregator. |
| 155 | 155 | * @return object the aggregator instance |
| 156 | 156 | */ |
| 157 | - public function createAggregator($config){ |
|
| 157 | + public function createAggregator($config) { |
|
| 158 | 158 | return $this->createReplyMessageHandler($config); |
| 159 | 159 | } |
| 160 | 160 | |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | * @param object $config configuration object for the wiretap. |
| 168 | 168 | * @return object the wiretap instance |
| 169 | 169 | */ |
| 170 | - public function createWiretap($config){ |
|
| 170 | + public function createWiretap($config) { |
|
| 171 | 171 | return $this->createReplyMessageHandler($config, '\PEIP\Listener\Wiretap'); |
| 172 | 172 | } |
| 173 | 173 | |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | * @param string $defaultClass the class to use if none is set in config. |
| 181 | 181 | * @return object the reply-message-handler instance |
| 182 | 182 | */ |
| 183 | - public function createReplyMessageHandler($config, $defaultClass = false){ |
|
| 183 | + public function createReplyMessageHandler($config, $defaultClass = false) { |
|
| 184 | 184 | return $this->buildAndModify($config, $this->getReplyHandlerArguments($config), $defaultClass); |
| 185 | 185 | } |
| 186 | 186 | |
@@ -193,12 +193,12 @@ discard block |
||
| 193 | 193 | * @param string $defaultClass the class to use if none is set in config. |
| 194 | 194 | * @return object the service-activator instance |
| 195 | 195 | */ |
| 196 | - public function createServiceActivator($config, $defaultClass = false){ |
|
| 196 | + public function createServiceActivator($config, $defaultClass = false) { |
|
| 197 | 197 | $method = (string)$config['method']; |
| 198 | 198 | $service = $this->context->getServiceProvider()->provideService((string)$config['ref']); |
| 199 | - if($method && $service){ |
|
| 199 | + if ($method && $service) { |
|
| 200 | 200 | $args = $this->getReplyHandlerArguments($config); |
| 201 | - array_unshift($args,array( |
|
| 201 | + array_unshift($args, array( |
|
| 202 | 202 | $service, |
| 203 | 203 | $method |
| 204 | 204 | )); |
@@ -215,12 +215,12 @@ discard block |
||
| 215 | 215 | * @param object $config configuration object to create arguments from. |
| 216 | 216 | * @return mixed build arguments |
| 217 | 217 | */ |
| 218 | - protected function getReplyHandlerArguments($config){ |
|
| 218 | + protected function getReplyHandlerArguments($config) { |
|
| 219 | 219 | $args = array( |
| 220 | 220 | $this->doGetChannel('input', $config), |
| 221 | 221 | $this->doGetChannel('output', $config) |
| 222 | 222 | ); |
| 223 | - if($args[0] == NULL){ |
|
| 223 | + if ($args[0] == NULL) { |
|
| 224 | 224 | throw new \RuntimeException('Could not receive input channel.'); |
| 225 | 225 | } |
| 226 | 226 | return $args; |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | * @param object $config configuration object to return request-channel from. |
| 236 | 236 | * @return \PEIP\INF\Channel\Channel request-channel |
| 237 | 237 | */ |
| 238 | - protected function getRequestChannel($config){ |
|
| 238 | + protected function getRequestChannel($config) { |
|
| 239 | 239 | return $this->doGetChannel('request', $config); |
| 240 | 240 | } |
| 241 | 241 | |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | * @param object $config configuration object to return reply-channel from. |
| 249 | 249 | * @return \PEIP\INF\Channel\Channel reply-channel |
| 250 | 250 | */ |
| 251 | - protected function getReplyChannel($config){ |
|
| 251 | + protected function getReplyChannel($config) { |
|
| 252 | 252 | return $this->doGetChannel('reply', $config); |
| 253 | 253 | } |
| 254 | 254 | |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | * @param object $config configuration object to return channel from. |
| 262 | 262 | * @return \PEIP\INF\Channel\Channel reply-channel |
| 263 | 263 | */ |
| 264 | - public function doGetChannel($type, $config){ |
|
| 264 | + public function doGetChannel($type, $config) { |
|
| 265 | 265 | $channelName = isset($config[$type."_channel"]) |
| 266 | 266 | ? $config[$type."_channel"] |
| 267 | 267 | : $config["default_".$type."_channel"]; |
@@ -12,7 +12,6 @@ |
||
| 12 | 12 | * @author timo |
| 13 | 13 | */ |
| 14 | 14 | use PEIP\Context\XMLContext; |
| 15 | -use PEIP\Plugins\BasePlugin; |
|
| 16 | 15 | |
| 17 | 16 | class ServiceProvider extends \PEIP\Service\ServiceContainer { |
| 18 | 17 | |
@@ -63,17 +63,17 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | - * Registers a callable as builder for given node-name |
|
| 67 | - * |
|
| 68 | - * @implements \PEIP\INF\Context\Context |
|
| 69 | - * @access public |
|
| 70 | - * @param string $nodeName the name of the node |
|
| 71 | - * @param callable $callable a callable which creates instances for node-name |
|
| 72 | - */ |
|
| 66 | + * Registers a callable as builder for given node-name |
|
| 67 | + * |
|
| 68 | + * @implements \PEIP\INF\Context\Context |
|
| 69 | + * @access public |
|
| 70 | + * @param string $nodeName the name of the node |
|
| 71 | + * @param callable $callable a callable which creates instances for node-name |
|
| 72 | + */ |
|
| 73 | 73 | public function registerNodeBuilder($nodeName, $callable){ |
| 74 | 74 | $this->nodeBuilders[$nodeName] = $callable; |
| 75 | 75 | } |
| 76 | - /** |
|
| 76 | + /** |
|
| 77 | 77 | * Registers the build-methods for the main-components with this context. |
| 78 | 78 | * Note: This method and subsequent registered methods of this class are |
| 79 | 79 | * candidates for refactoring. Because this class has grown much to large |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | 'service' => 'initService' |
| 89 | 89 | ); |
| 90 | 90 | foreach($builders as $nodeName => $method){ |
| 91 | - $this->registerNodeBuilder($nodeName, array($this, $method)); |
|
| 91 | + $this->registerNodeBuilder($nodeName, array($this, $method)); |
|
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | use PEIP\Context\XMLContext; |
| 15 | 15 | use PEIP\Plugins\BasePlugin; |
| 16 | 16 | |
| 17 | -class ServiceProvider extends \PEIP\Service\ServiceContainer { |
|
| 17 | +class ServiceProvider extends \PEIP\Service\ServiceContainer { |
|
| 18 | 18 | |
| 19 | 19 | const |
| 20 | 20 | /* Headers */ |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | public function __construct(array $config = array(), $idAttribute = 'id') { |
| 48 | 48 | $this->idAttribute = $idAttribute; |
| 49 | 49 | $this->initNodeBuilders(); |
| 50 | - foreach($config as $serviceConfig){ |
|
| 50 | + foreach ($config as $serviceConfig) { |
|
| 51 | 51 | $this->addConfig($serviceConfig); |
| 52 | 52 | } |
| 53 | 53 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * @access public |
| 59 | 59 | * @return array registered services |
| 60 | 60 | */ |
| 61 | - public function getServices(){ |
|
| 61 | + public function getServices() { |
|
| 62 | 62 | return $this->services; |
| 63 | 63 | } |
| 64 | 64 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | * @param string $nodeName the name of the node |
| 71 | 71 | * @param callable $callable a callable which creates instances for node-name |
| 72 | 72 | */ |
| 73 | - public function registerNodeBuilder($nodeName, $callable){ |
|
| 73 | + public function registerNodeBuilder($nodeName, $callable) { |
|
| 74 | 74 | $this->nodeBuilders[$nodeName] = $callable; |
| 75 | 75 | } |
| 76 | 76 | /** |
@@ -83,16 +83,16 @@ discard block |
||
| 83 | 83 | * @see XMLContext::includeContext |
| 84 | 84 | * @access protected |
| 85 | 85 | */ |
| 86 | - protected function initNodeBuilders(){ |
|
| 86 | + protected function initNodeBuilders() { |
|
| 87 | 87 | $builders = array( |
| 88 | 88 | 'service' => 'initService' |
| 89 | 89 | ); |
| 90 | - foreach($builders as $nodeName => $method){ |
|
| 90 | + foreach ($builders as $nodeName => $method) { |
|
| 91 | 91 | $this->registerNodeBuilder($nodeName, array($this, $method)); |
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - public function addConfig($config){ |
|
| 95 | + public function addConfig($config) { |
|
| 96 | 96 | $this->doFireEvent( |
| 97 | 97 | self::EVENT_BEFORE_ADD_CONFIG, |
| 98 | 98 | array( |
@@ -111,15 +111,15 @@ discard block |
||
| 111 | 111 | ); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - public function provideService($key){ |
|
| 114 | + public function provideService($key) { |
|
| 115 | 115 | $this->doFireEvent(self::EVENT_BEFORE_PROVIDE_SERVICE, array( |
| 116 | 116 | self::HEADER_KEY=>$key) |
| 117 | 117 | ); |
| 118 | 118 | |
| 119 | - if($this->hasService($key)){ |
|
| 120 | - $service = $this->getService($key); |
|
| 121 | - }else{ |
|
| 122 | - $service = $this->createService($key); |
|
| 119 | + if ($this->hasService($key)) { |
|
| 120 | + $service = $this->getService($key); |
|
| 121 | + }else { |
|
| 122 | + $service = $this->createService($key); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | $this->doFireEvent(self::EVENT_AFTER_PROVIDE_SERVICE, array( |
@@ -130,16 +130,16 @@ discard block |
||
| 130 | 130 | return $service; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - protected function createService($key){ |
|
| 133 | + protected function createService($key) { |
|
| 134 | 134 | $this->doFireEvent(self::EVENT_BEFORE_CREATE_SERVICE, array( |
| 135 | 135 | self::HEADER_KEY=>$key) |
| 136 | 136 | ); |
| 137 | 137 | $errorMessage = ''; |
| 138 | 138 | $config = $this->getServiceConfig($key); |
| 139 | 139 | |
| 140 | - if($config){ |
|
| 140 | + if ($config) { |
|
| 141 | 141 | $node = $this->buildNode($config); |
| 142 | - if($node){ |
|
| 142 | + if ($node) { |
|
| 143 | 143 | $this->setService( |
| 144 | 144 | $key, |
| 145 | 145 | $node |
@@ -150,11 +150,11 @@ discard block |
||
| 150 | 150 | )); |
| 151 | 151 | |
| 152 | 152 | return $node; |
| 153 | - }else{ |
|
| 153 | + }else { |
|
| 154 | 154 | $errorMessage = 'COULD NOT BUILD NODE FOR KEY: '.$key; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - }else{ |
|
| 157 | + }else { |
|
| 158 | 158 | $errorMessage = 'NO CONFIG FOR KEY: '.$key; |
| 159 | 159 | } |
| 160 | 160 | $this->doFireEvent(self::EVENT_CREATE_SERVICE_ERROR, array( |
@@ -164,8 +164,8 @@ discard block |
||
| 164 | 164 | return NULL; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - public function getServiceConfig($key){ |
|
| 168 | - if(!isset($this->ids[$key])){ |
|
| 167 | + public function getServiceConfig($key) { |
|
| 168 | + if (!isset($this->ids[$key])) { |
|
| 169 | 169 | return false; |
| 170 | 170 | } |
| 171 | 171 | return $this->config[$this->ids[$key]]; |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | * @param object $config configuration-node |
| 181 | 181 | * @return void |
| 182 | 182 | */ |
| 183 | - protected function buildNode($config){ |
|
| 183 | + protected function buildNode($config) { |
|
| 184 | 184 | $nodeName = (string)$config['type']; |
| 185 | 185 | |
| 186 | 186 | $this->doFireEvent(self::EVENT_BEFORE_BUILD_NODE, array( |
@@ -188,20 +188,20 @@ discard block |
||
| 188 | 188 | self::HEADER_NODE_NAME=> $nodeName |
| 189 | 189 | )); |
| 190 | 190 | // call the builder method registered for the node. |
| 191 | - if(array_key_exists($nodeName, $this->nodeBuilders)){ |
|
| 191 | + if (array_key_exists($nodeName, $this->nodeBuilders)) { |
|
| 192 | 192 | |
| 193 | 193 | $nodeInstance = call_user_func($this->nodeBuilders[$nodeName], $config); |
| 194 | - if(is_object($nodeInstance)){ |
|
| 194 | + if (is_object($nodeInstance)) { |
|
| 195 | 195 | $this->doFireEvent(self::EVENT_BUILD_NODE_SUCCESS, array( |
| 196 | 196 | self::HEADER_NODE_CONFIG=>$config, |
| 197 | 197 | self::HEADER_NODE_NAME=> $nodeName, |
| 198 | 198 | self::HEADER_NODE => $nodeInstance |
| 199 | 199 | )); |
| 200 | 200 | return $nodeInstance; |
| 201 | - }else{ |
|
| 201 | + }else { |
|
| 202 | 202 | $errorMessage = 'BUILDER RETURNED NO OBJECT FOR NODE-TYPE: '.$nodeName; |
| 203 | 203 | } |
| 204 | - }else{ |
|
| 204 | + }else { |
|
| 205 | 205 | $errorMessage = 'NO BUILDER FOUND FOR NODE-TYPE: '.$nodeName; |
| 206 | 206 | } |
| 207 | 207 | |
@@ -212,27 +212,27 @@ discard block |
||
| 212 | 212 | )); |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - protected function getIdFromConfig($config){ |
|
| 215 | + protected function getIdFromConfig($config) { |
|
| 216 | 216 | $id = ''; |
| 217 | - if(isset($config[$this->idAttribute])){ |
|
| 217 | + if (isset($config[$this->idAttribute])) { |
|
| 218 | 218 | $id = trim((string)($config[$this->idAttribute])); |
| 219 | 219 | } |
| 220 | 220 | return $id; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - protected function getCountConfig(){ |
|
| 223 | + protected function getCountConfig() { |
|
| 224 | 224 | return count($this->config); |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - protected function doAddConfig($config){ |
|
| 227 | + protected function doAddConfig($config) { |
|
| 228 | 228 | $countConfig = $this->getCountConfig(); |
| 229 | 229 | $this->config[$countConfig] = $config; |
| 230 | 230 | return $countConfig; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - protected function doRegisterConfig($config){ |
|
| 234 | - $id = $this->getIdFromConfig($config); |
|
| 235 | - if($id != ''){ |
|
| 233 | + protected function doRegisterConfig($config) { |
|
| 234 | + $id = $this->getIdFromConfig($config); |
|
| 235 | + if ($id != '') { |
|
| 236 | 236 | $this->ids[$id] = $this->getCountConfig() - 1; |
| 237 | 237 | } |
| 238 | 238 | return $id; |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | if($this->hasService($key)){ |
| 120 | 120 | $service = $this->getService($key); |
| 121 | - }else{ |
|
| 121 | + } else{ |
|
| 122 | 122 | $service = $this->createService($key); |
| 123 | 123 | } |
| 124 | 124 | |
@@ -150,11 +150,11 @@ discard block |
||
| 150 | 150 | )); |
| 151 | 151 | |
| 152 | 152 | return $node; |
| 153 | - }else{ |
|
| 153 | + } else{ |
|
| 154 | 154 | $errorMessage = 'COULD NOT BUILD NODE FOR KEY: '.$key; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - }else{ |
|
| 157 | + } else{ |
|
| 158 | 158 | $errorMessage = 'NO CONFIG FOR KEY: '.$key; |
| 159 | 159 | } |
| 160 | 160 | $this->doFireEvent(self::EVENT_CREATE_SERVICE_ERROR, array( |
@@ -198,10 +198,10 @@ discard block |
||
| 198 | 198 | self::HEADER_NODE => $nodeInstance |
| 199 | 199 | )); |
| 200 | 200 | return $nodeInstance; |
| 201 | - }else{ |
|
| 201 | + } else{ |
|
| 202 | 202 | $errorMessage = 'BUILDER RETURNED NO OBJECT FOR NODE-TYPE: '.$nodeName; |
| 203 | 203 | } |
| 204 | - }else{ |
|
| 204 | + } else{ |
|
| 205 | 205 | $errorMessage = 'NO BUILDER FOUND FOR NODE-TYPE: '.$nodeName; |
| 206 | 206 | } |
| 207 | 207 | |
@@ -38,16 +38,16 @@ discard block |
||
| 38 | 38 | * @param $parameters |
| 39 | 39 | * @return |
| 40 | 40 | */ |
| 41 | - protected function __construct($callable ,array $parameters = array()){ |
|
| 41 | + protected function __construct($callable, array $parameters = array()) { |
|
| 42 | 42 | $this->callable = $callable; |
| 43 | 43 | $this->setParameters($parameters); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - public static function getfromClass($class, array $parameters = array()){ |
|
| 46 | + public static function getfromClass($class, array $parameters = array()) { |
|
| 47 | 47 | return new DedicatedFactory(array($class, '__construct'), $parameters); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - public static function getfromCallable($callable, array $parameters = array()){ |
|
| 50 | + public static function getfromCallable($callable, array $parameters = array()) { |
|
| 51 | 51 | return new DedicatedFactory($callable, $parameters); |
| 52 | 52 | } |
| 53 | 53 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * @param $arguments |
| 58 | 58 | * @return |
| 59 | 59 | */ |
| 60 | - public function build(array $arguments = array()){ |
|
| 60 | + public function build(array $arguments = array()) { |
|
| 61 | 61 | $arguments = count($arguments) > 0 ? $arguments : $this->getParameters(); |
| 62 | 62 | return (is_array($this->callable) && $this->callable[1] == '__construct') |
| 63 | 63 | ? GenericBuilder::GetInstance($this->callable[0])->build($arguments) |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | * @param $method |
| 71 | 71 | * @return |
| 72 | 72 | */ |
| 73 | - public function setConstructor($method){ |
|
| 73 | + public function setConstructor($method) { |
|
| 74 | 74 | $this->constructor = (string)$method; |
| 75 | 75 | return $this; |
| 76 | 76 | } |
@@ -22,42 +22,42 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | class XMLArrayTranslator { |
| 24 | 24 | |
| 25 | - public static function translate($content){ |
|
| 25 | + public static function translate($content) { |
|
| 26 | 26 | try { |
| 27 | 27 | $node = simplexml_load_string($content); |
| 28 | 28 | // fix for hhvm |
| 29 | - if(!($node instanceof \SimpleXMLElement)){ |
|
| 29 | + if (!($node instanceof \SimpleXMLElement)) { |
|
| 30 | 30 | throw new \Exception('loading XML failed'); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | } |
| 34 | - catch(\Exception $e){ |
|
| 34 | + catch (\Exception $e) { |
|
| 35 | 35 | return false; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | return self::doTranslate($node); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - protected static function doTranslate(\SimpleXMLElement $node){ |
|
| 41 | + protected static function doTranslate(\SimpleXMLElement $node) { |
|
| 42 | 42 | |
| 43 | 43 | $array = array(); |
| 44 | 44 | $array['type'] = $node['type'] |
| 45 | 45 | ? (string)$node['type'] |
| 46 | 46 | : (string)$node->getName(); |
| 47 | 47 | $value = (string)$node; |
| 48 | - if($value != ''){ |
|
| 48 | + if ($value != '') { |
|
| 49 | 49 | $array['value'] = $value; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - foreach($node->attributes() as $name=>$value){ |
|
| 52 | + foreach ($node->attributes() as $name=>$value) { |
|
| 53 | 53 | $array[$name] = (string)$value; |
| 54 | 54 | } |
| 55 | - foreach($node->children() as $nr=>$child){ |
|
| 55 | + foreach ($node->children() as $nr=>$child) { |
|
| 56 | 56 | $name = $child->getName(); |
| 57 | 57 | $res = self::doTranslate($child); |
| 58 | 58 | |
| 59 | - if(isset($array[$name])){ |
|
| 60 | - if(is_string($array[$name])){ |
|
| 59 | + if (isset($array[$name])) { |
|
| 60 | + if (is_string($array[$name])) { |
|
| 61 | 61 | $array[$name] = array( |
| 62 | 62 | array( |
| 63 | 63 | 'type'=>$name, |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | ) |
| 66 | 66 | ); |
| 67 | 67 | } |
| 68 | - }else{ |
|
| 68 | + }else { |
|
| 69 | 69 | $array[$name] = array(); |
| 70 | 70 | } |
| 71 | 71 | $array[$name][] = $res; |
@@ -30,8 +30,7 @@ discard block |
||
| 30 | 30 | throw new \Exception('loading XML failed'); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - } |
|
| 34 | - catch(\Exception $e){ |
|
| 33 | + } catch(\Exception $e){ |
|
| 35 | 34 | return false; |
| 36 | 35 | } |
| 37 | 36 | |
@@ -65,7 +64,7 @@ discard block |
||
| 65 | 64 | ) |
| 66 | 65 | ); |
| 67 | 66 | } |
| 68 | - }else{ |
|
| 67 | + } else{ |
|
| 69 | 68 | $array[$name] = array(); |
| 70 | 69 | } |
| 71 | 70 | $array[$name][] = $res; |
@@ -19,21 +19,21 @@ |
||
| 19 | 19 | protected $config; |
| 20 | 20 | |
| 21 | 21 | |
| 22 | - public function __construct($config){ |
|
| 22 | + public function __construct($config) { |
|
| 23 | 23 | $this->config = ($config); |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - public function read(){ |
|
| 26 | + public function read() { |
|
| 27 | 27 | $iterator = new \SimpleXMLIterator($this->config); |
| 28 | 28 | $iterator->rewind(); |
| 29 | - while($iterator->valid()){ |
|
| 29 | + while ($iterator->valid()) { |
|
| 30 | 30 | |
| 31 | 31 | $arrayNode = XMLArrayTranslator::translate($iterator->current()->asXML()); |
| 32 | 32 | $this->doFireEvent('read_node', array('NODE'=>$arrayNode)); |
| 33 | 33 | $iterator->next(); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - foreach($iterator as $xmlNode){ |
|
| 36 | + foreach ($iterator as $xmlNode) { |
|
| 37 | 37 | |
| 38 | 38 | } |
| 39 | 39 | $this->config = array(); |