@@ -47,6 +47,9 @@ |
||
| 47 | 47 | return new DedicatedFactory(array($class, '__construct'), $parameters); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | + /** |
|
| 51 | + * @param string[] $callable |
|
| 52 | + */ |
|
| 50 | 53 | public static function getfromCallable($callable, array $parameters = array()){
|
| 51 | 54 | return new DedicatedFactory($callable, $parameters); |
| 52 | 55 | } |
@@ -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 | } |
@@ -71,7 +71,7 @@ |
||
| 71 | 71 | * @see GenericBuilder |
| 72 | 72 | * @static |
| 73 | 73 | * @access protected |
| 74 | - * @param object $className name of class to build instance for. |
|
| 74 | + * @param string $className name of class to build instance for. |
|
| 75 | 75 | * @param array $arguments arguments for the constructor |
| 76 | 76 | * @return object build and modified srvice instance |
| 77 | 77 | */ |
@@ -11,8 +11,8 @@ |
||
| 11 | 11 | * |
| 12 | 12 | * @author timo |
| 13 | 13 | */ |
| 14 | -use PEIP\Util\Test; |
|
| 15 | -use PEIP\Base\GenericBuilder; |
|
| 14 | +use PEIP\Util\Test; |
|
| 15 | +use PEIP\Base\GenericBuilder; |
|
| 16 | 16 | use PEIP\Context\XMLContext; |
| 17 | 17 | |
| 18 | 18 | class ServiceFactory {
|
@@ -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 |
|
| 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 |
|
| 24 | + * @return object the initialized service instance |
|
| 25 | + */ |
|
| 26 | 26 | public static function createService($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 = $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 static 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($config, $arguments, $defaultClass = false){
|
| 130 | 130 | if("" != (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 | } |
@@ -51,10 +51,10 @@ discard block |
||
| 51 | 51 | $constructor = isset($config["constructor"])?(string)$config["constructor"]:""; |
| 52 | 52 | if($constructor != '' && Test::assertMethod($cls, $constructor)){
|
| 53 | 53 | $service = call_user_func_array(array($cls, $constructor), $arguments); |
| 54 | - }else{
|
|
| 54 | + } else{
|
|
| 55 | 55 | $service = self::build($cls, $arguments); |
| 56 | 56 | } |
| 57 | - }catch(\Exception $e){
|
|
| 57 | + } catch(\Exception $e){
|
|
| 58 | 58 | throw new \RuntimeException('Could not create Service "'.$cls.'" -> '.$e->getMessage());
|
| 59 | 59 | } |
| 60 | 60 | } |
@@ -89,26 +89,26 @@ discard block |
||
| 89 | 89 | protected static function buildArg($config){
|
| 90 | 90 | if(trim((string)$config['value']) != ''){
|
| 91 | 91 | $arg = (string)$config['value']; |
| 92 | - }elseif($config->getName() == 'value'){
|
|
| 92 | + } elseif($config->getName() == 'value'){
|
|
| 93 | 93 | $arg = (string)$config; |
| 94 | - }elseif($config->getName() == 'list'){
|
|
| 94 | + } elseif($config->getName() == 'list'){
|
|
| 95 | 95 | $arg = array(); |
| 96 | 96 | foreach($config->children() as $entry){
|
| 97 | 97 | if($entry->getName() == 'value'){
|
| 98 | 98 | if($entry['key']){
|
| 99 | 99 | $arg[(string)$entry['key']] = (string)$entry; |
| 100 | - }else{
|
|
| 100 | + } else{
|
|
| 101 | 101 | $arg[] = (string)$entry; |
| 102 | 102 | } |
| 103 | - }elseif($entry->getName() == 'service'){
|
|
| 103 | + } elseif($entry->getName() == 'service'){
|
|
| 104 | 104 | $arg[] = $this->provideService($entry); |
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | - }elseif($config->getName() == 'service'){
|
|
| 107 | + } elseif($config->getName() == 'service'){
|
|
| 108 | 108 | $arg = self::provideService($config); |
| 109 | - }elseif($config->list){
|
|
| 109 | + } elseif($config->list){
|
|
| 110 | 110 | $arg = self::buildArg($config->list); |
| 111 | - }elseif($config->service){
|
|
| 111 | + } elseif($config->service){
|
|
| 112 | 112 | $arg = self::buildArg($config->service); |
| 113 | 113 | } |
| 114 | 114 | return $arg; |
@@ -129,12 +129,12 @@ discard block |
||
| 129 | 129 | public static function buildAndModify($config, $arguments, $defaultClass = ""){
|
| 130 | 130 | if((isset($config["class"]) && "" != (string)$config["class"]) || $defaultClass !== ""){
|
| 131 | 131 | $service = ServiceFactory::doBuild($config, $arguments, $defaultClass); |
| 132 | - }else{
|
|
| 132 | + } else{
|
|
| 133 | 133 | throw new \RuntimeException('Could not create Service. no class or reference given.');
|
| 134 | 134 | } |
| 135 | 135 | if(isset($config["ref_property"])){
|
| 136 | 136 | $service = $service->{(string)$config["ref_property"]};
|
| 137 | - }elseif(isset($config["ref_method"])){
|
|
| 137 | + } elseif(isset($config["ref_method"])){
|
|
| 138 | 138 | $args = array(); |
| 139 | 139 | if($config->argument){
|
| 140 | 140 | foreach($config->argument as $arg){
|
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | $setter = self::getSetter($property); |
| 178 | 178 | if($setter && self::hasPublicProperty($service, 'Method', $setter)){
|
| 179 | 179 | $service->{$setter}($arg);
|
| 180 | - }elseif(in_array($property, self::hasPublicProperty($service, 'Property', $setter))){
|
|
| 180 | + } elseif(in_array($property, self::hasPublicProperty($service, 'Property', $setter))){
|
|
| 181 | 181 | $service->$setter = $arg; |
| 182 | 182 | } |
| 183 | 183 | } |
@@ -23,11 +23,11 @@ discard block |
||
| 23 | 23 | * @param $config |
| 24 | 24 | * @return object the initialized service instance |
| 25 | 25 | */ |
| 26 | - public static function createService($config){
|
|
| 26 | + public static function createService($config) {
|
|
| 27 | 27 | $args = array(); |
| 28 | 28 | //build arguments for constructor |
| 29 | - if($config->constructor_arg){
|
|
| 30 | - foreach($config->constructor_arg as $arg){
|
|
| 29 | + if ($config->constructor_arg) {
|
|
| 30 | + foreach ($config->constructor_arg as $arg) {
|
|
| 31 | 31 | $args[] = self::buildArg($arg); |
| 32 | 32 | } |
| 33 | 33 | } |
@@ -44,21 +44,21 @@ discard block |
||
| 44 | 44 | * @param string $defaultClass class to create instance for if none is set in config |
| 45 | 45 | * @return object build and modified srvice instance |
| 46 | 46 | */ |
| 47 | - public static function doBuild($config, $arguments, $defaultClass = false){
|
|
| 47 | + public static function doBuild($config, $arguments, $defaultClass = false) {
|
|
| 48 | 48 | $cls = isset($config["class"]) ? trim((string)$config["class"]) : (string)$defaultClass; |
| 49 | - if($cls != ''){
|
|
| 49 | + if ($cls != '') {
|
|
| 50 | 50 | try {
|
| 51 | - $constructor = isset($config["constructor"])?(string)$config["constructor"]:""; |
|
| 52 | - if($constructor != '' && Test::assertMethod($cls, $constructor)){
|
|
| 51 | + $constructor = isset($config["constructor"]) ? (string)$config["constructor"] : ""; |
|
| 52 | + if ($constructor != '' && Test::assertMethod($cls, $constructor)) {
|
|
| 53 | 53 | $service = call_user_func_array(array($cls, $constructor), $arguments); |
| 54 | - }else{
|
|
| 54 | + }else {
|
|
| 55 | 55 | $service = self::build($cls, $arguments); |
| 56 | 56 | } |
| 57 | - }catch(\Exception $e){
|
|
| 57 | + } catch (\Exception $e) {
|
|
| 58 | 58 | throw new \RuntimeException('Could not create Service "'.$cls.'" -> '.$e->getMessage());
|
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | - if(is_object($service)){
|
|
| 61 | + if (is_object($service)) {
|
|
| 62 | 62 | return $service; |
| 63 | 63 | } |
| 64 | 64 | throw new \RuntimeException('Could not create Service "'.$cls.'". Class does not exist.');
|
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * @param array $arguments arguments for the constructor |
| 76 | 76 | * @return object build and modified srvice instance |
| 77 | 77 | */ |
| 78 | - public static function build($className, $arguments){
|
|
| 78 | + public static function build($className, $arguments) {
|
|
| 79 | 79 | return GenericBuilder::getInstance($className)->build($arguments); |
| 80 | 80 | } |
| 81 | 81 | |
@@ -86,29 +86,29 @@ discard block |
||
| 86 | 86 | * @param object $config configuration object to create argument from. |
| 87 | 87 | * @return mixed build argument |
| 88 | 88 | */ |
| 89 | - protected function buildArg($config){
|
|
| 90 | - if(trim((string)$config['value']) != ''){
|
|
| 89 | + protected function buildArg($config) {
|
|
| 90 | + if (trim((string)$config['value']) != '') {
|
|
| 91 | 91 | $arg = (string)$config['value']; |
| 92 | - }elseif($config->getName() == 'value'){
|
|
| 92 | + }elseif ($config->getName() == 'value') {
|
|
| 93 | 93 | $arg = (string)$config; |
| 94 | - }elseif($config->getName() == 'list'){
|
|
| 94 | + }elseif ($config->getName() == 'list') {
|
|
| 95 | 95 | $arg = array(); |
| 96 | - foreach($config->children() as $entry){
|
|
| 97 | - if($entry->getName() == 'value'){
|
|
| 98 | - if($entry['key']){
|
|
| 96 | + foreach ($config->children() as $entry) {
|
|
| 97 | + if ($entry->getName() == 'value') {
|
|
| 98 | + if ($entry['key']) {
|
|
| 99 | 99 | $arg[(string)$entry['key']] = (string)$entry; |
| 100 | - }else{
|
|
| 100 | + }else {
|
|
| 101 | 101 | $arg[] = (string)$entry; |
| 102 | 102 | } |
| 103 | - }elseif($entry->getName() == 'service'){
|
|
| 103 | + }elseif ($entry->getName() == 'service') {
|
|
| 104 | 104 | $arg[] = $this->provideService($entry); |
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | - }elseif($config->getName() == 'service'){
|
|
| 107 | + }elseif ($config->getName() == 'service') {
|
|
| 108 | 108 | $arg = self::provideService($config); |
| 109 | - }elseif($config->list){
|
|
| 109 | + }elseif ($config->list) {
|
|
| 110 | 110 | $arg = $this->buildArg($config->list); |
| 111 | - }elseif($config->service){
|
|
| 111 | + }elseif ($config->service) {
|
|
| 112 | 112 | $arg = $this->buildArg($config->service); |
| 113 | 113 | } |
| 114 | 114 | return $arg; |
@@ -126,24 +126,24 @@ discard block |
||
| 126 | 126 | * @param string $defaultClass class to create instance for if none is set in config |
| 127 | 127 | * @return object build and modified srvice instance |
| 128 | 128 | */ |
| 129 | - public static function buildAndModify($config, $arguments, $defaultClass = ""){
|
|
| 130 | - if((isset($config["class"]) && "" != (string)$config["class"]) || $defaultClass !== ""){
|
|
| 129 | + public static function buildAndModify($config, $arguments, $defaultClass = "") {
|
|
| 130 | + if ((isset($config["class"]) && "" != (string)$config["class"]) || $defaultClass !== "") {
|
|
| 131 | 131 | $service = ServiceFactory::doBuild($config, $arguments, $defaultClass); |
| 132 | - }else{
|
|
| 132 | + }else {
|
|
| 133 | 133 | throw new \RuntimeException('Could not create Service. no class or reference given.');
|
| 134 | 134 | } |
| 135 | - if(isset($config["ref_property"])){
|
|
| 135 | + if (isset($config["ref_property"])) {
|
|
| 136 | 136 | $service = $service->{(string)$config["ref_property"]};
|
| 137 | - }elseif(isset($config["ref_method"])){
|
|
| 137 | + }elseif (isset($config["ref_method"])) {
|
|
| 138 | 138 | $args = array(); |
| 139 | - if($config->argument){
|
|
| 140 | - foreach($config->argument as $arg){
|
|
| 139 | + if ($config->argument) {
|
|
| 140 | + foreach ($config->argument as $arg) {
|
|
| 141 | 141 | $args[] = $this->buildArg($arg); |
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | $service = call_user_func_array(array($service, (string)$config["ref_method"]), $args); |
| 145 | 145 | } |
| 146 | - if(!is_object($service)){
|
|
| 146 | + if (!is_object($service)) {
|
|
| 147 | 147 | throw new \RuntimeException('Could not create Service.');
|
| 148 | 148 | } |
| 149 | 149 | $service = self::modifyService($service, $config); |
@@ -166,30 +166,30 @@ discard block |
||
| 166 | 166 | * @param object $config configuration to get the modification instructions from. |
| 167 | 167 | * @return object the modificated service |
| 168 | 168 | */ |
| 169 | - protected function modifyService($service, $config){
|
|
| 169 | + protected function modifyService($service, $config) {
|
|
| 170 | 170 | $config = is_array($config) ? new \ArrayObject($config) : $config; |
| 171 | 171 | $reflection = GenericBuilder::getInstance(get_class($service))->getReflectionClass(); |
| 172 | 172 | // set instance properties |
| 173 | - if(isset($config->property)){
|
|
| 174 | - foreach($config->property as $property){
|
|
| 173 | + if (isset($config->property)) {
|
|
| 174 | + foreach ($config->property as $property) {
|
|
| 175 | 175 | $arg = $this->buildArg($property); |
| 176 | - if($arg){
|
|
| 176 | + if ($arg) {
|
|
| 177 | 177 | $setter = self::getSetter($property); |
| 178 | - if($setter && self::hasPublicProperty($service, 'Method', $setter)){
|
|
| 178 | + if ($setter && self::hasPublicProperty($service, 'Method', $setter)) {
|
|
| 179 | 179 | $service->{$setter}($arg);
|
| 180 | - }elseif(in_array($property, self::hasPublicProperty($service, 'Property', $setter))){
|
|
| 180 | + }elseif (in_array($property, self::hasPublicProperty($service, 'Property', $setter))) {
|
|
| 181 | 181 | $service->$setter = $arg; |
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | // call instance methods |
| 187 | - if(isset($config->action)){
|
|
| 188 | - foreach($config->action as $action){
|
|
| 187 | + if (isset($config->action)) {
|
|
| 188 | + foreach ($config->action as $action) {
|
|
| 189 | 189 | $method = (string)$action['method'] != '' ? (string)$action['method'] : NULL; |
| 190 | - if($method && self::hasPublicProperty($service, 'Method', $method)){
|
|
| 190 | + if ($method && self::hasPublicProperty($service, 'Method', $method)) {
|
|
| 191 | 191 | $args = array(); |
| 192 | - foreach($action->children() as $argument){
|
|
| 192 | + foreach ($action->children() as $argument) {
|
|
| 193 | 193 | $args[] = $this->buildArg($argument); |
| 194 | 194 | } |
| 195 | 195 | call_user_func_array(array($service, (string)$action['method']), $args); |
@@ -197,9 +197,9 @@ discard block |
||
| 197 | 197 | } |
| 198 | 198 | } |
| 199 | 199 | // register instance listeners |
| 200 | - if($service instanceof \PEIP\INF\Event\Connectable){
|
|
| 201 | - if(isset($config->listener)){
|
|
| 202 | - foreach($config->listener as $listenerConf){
|
|
| 200 | + if ($service instanceof \PEIP\INF\Event\Connectable) {
|
|
| 201 | + if (isset($config->listener)) {
|
|
| 202 | + foreach ($config->listener as $listenerConf) {
|
|
| 203 | 203 | $event = (string)$listenerConf['event']; |
| 204 | 204 | $listener = $this->provideService($listenerConf); |
| 205 | 205 | $service->connect($event, $listener); |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | * @implements \PEIP\INF\Gateway\MessagingGateway, \PEIP\INF\Message\MessageBuilder |
| 21 | 21 | */ |
| 22 | 22 | |
| 23 | -use PEIP\Message\GenericMessage; |
|
| 23 | +use PEIP\Message\GenericMessage; |
|
| 24 | 24 | use PEIP\Message\MessageBuilder; |
| 25 | 25 | |
| 26 | 26 | class SimpleMessagingGateway |
@@ -43,9 +43,9 @@ discard block |
||
| 43 | 43 | * @param \PEIP\INF\Channel\PollableChannel $replyChannel The default channel to receive requests from the gateway |
| 44 | 44 | * @param array $defaultHeaders The default headers to apply to request messages |
| 45 | 45 | */ |
| 46 | - public function __construct(\PEIP\INF\Channel\Channel $requestChannel, \PEIP\INF\Channel\Channel $replyChannel = NULL, array $defaultHeaders = array()){
|
|
| 46 | + public function __construct(\PEIP\INF\Channel\Channel $requestChannel, \PEIP\INF\Channel\Channel $replyChannel = NULL, array $defaultHeaders = array()) {
|
|
| 47 | 47 | $this->setRequestChannel($requestChannel); |
| 48 | - if($replyChannel){
|
|
| 48 | + if ($replyChannel) {
|
|
| 49 | 49 | $this->setReplyChannel($replyChannel); |
| 50 | 50 | } |
| 51 | 51 | $this->defaultHeaders = $defaultHeaders; |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * @param \PEIP\INF\Channel\Channel $replyChannel The default channel to receive requests from the gateway |
| 60 | 60 | * @return |
| 61 | 61 | */ |
| 62 | - public function setRequestChannel(\PEIP\INF\Channel\Channel $requestChannel){
|
|
| 62 | + public function setRequestChannel(\PEIP\INF\Channel\Channel $requestChannel) {
|
|
| 63 | 63 | $this->requestChannel = $requestChannel; |
| 64 | 64 | } |
| 65 | 65 | |
@@ -70,8 +70,8 @@ discard block |
||
| 70 | 70 | * @param \PEIP\INF\Channel\PollableChannel $replyChannel The default channel to receive requests from the gateway |
| 71 | 71 | * @return |
| 72 | 72 | */ |
| 73 | - public function setReplyChannel(\PEIP\INF\Channel\Channel $replyChannel){
|
|
| 74 | - if(!($replyChannel instanceof \PEIP\INF\Channel\PollableChannel)){
|
|
| 73 | + public function setReplyChannel(\PEIP\INF\Channel\Channel $replyChannel) {
|
|
| 74 | + if (!($replyChannel instanceof \PEIP\INF\Channel\PollableChannel)) {
|
|
| 75 | 75 | throw new \InvalidArgumentException('reply channel must be instance of \PEIP\INF\Channel\PollableChannel.');
|
| 76 | 76 | } |
| 77 | 77 | $this->replyChannel = $replyChannel; |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | * @param mixed $content the content/payload for the message to send |
| 85 | 85 | * @return |
| 86 | 86 | */ |
| 87 | - public function send($content){
|
|
| 87 | + public function send($content) {
|
|
| 88 | 88 | return $this->requestChannel->send($this->buildMessage($content)); |
| 89 | 89 | } |
| 90 | 90 | |
@@ -94,12 +94,12 @@ discard block |
||
| 94 | 94 | * @access public |
| 95 | 95 | * @return mixed content/payload of the received message |
| 96 | 96 | */ |
| 97 | - public function receive(){
|
|
| 98 | - if(!isset($this->replyChannel)){
|
|
| 97 | + public function receive() {
|
|
| 98 | + if (!isset($this->replyChannel)) {
|
|
| 99 | 99 | throw new \LogicException('No replyChannel set.');
|
| 100 | 100 | } |
| 101 | 101 | $message = $this->replyChannel->receive(); |
| 102 | - if($message){
|
|
| 102 | + if ($message) {
|
|
| 103 | 103 | return $message->getContent(); |
| 104 | 104 | } |
| 105 | 105 | return NULL; |
@@ -112,12 +112,12 @@ discard block |
||
| 112 | 112 | * @param mixed $content the content/payload for the message to send |
| 113 | 113 | * @return mixed content/payload of the received message |
| 114 | 114 | */ |
| 115 | - public function sendAndReceive($content){
|
|
| 115 | + public function sendAndReceive($content) {
|
|
| 116 | 116 | $this->send($content); |
| 117 | 117 | try {
|
| 118 | 118 | $res = $this->receive(); |
| 119 | 119 | } |
| 120 | - catch(\Exception $e){
|
|
| 120 | + catch (\Exception $e) {
|
|
| 121 | 121 | return NULL; |
| 122 | 122 | } |
| 123 | 123 | return $res; |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | * @param mixed $content the content/payload for the message to send |
| 131 | 131 | * @return \PEIP\INF\Message\Message the built message |
| 132 | 132 | */ |
| 133 | - protected function buildMessage($content){
|
|
| 133 | + protected function buildMessage($content) {
|
|
| 134 | 134 | return $this->getMessageBuilder()->setContent($content)->build(); |
| 135 | 135 | } |
| 136 | 136 | |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | * @access protected |
| 141 | 141 | * @return MessageBuilder message builder instance for the registerd message class |
| 142 | 142 | */ |
| 143 | - protected function getMessageBuilder(){
|
|
| 143 | + protected function getMessageBuilder() {
|
|
| 144 | 144 | return isset($this->messageBuilder) && ($this->messageBuilder->getMessageClass() == $this->getMessageClass()) |
| 145 | 145 | ? $this->messageBuilder |
| 146 | 146 | : $this->messageBuilder = MessageBuilder::getInstance($this->messageClass)->setHeaders($this->defaultHeaders); |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | * @param string $messageClass message class to create instances from |
| 154 | 154 | * @return |
| 155 | 155 | */ |
| 156 | - public function setMessageClass($messageClass){
|
|
| 156 | + public function setMessageClass($messageClass) {
|
|
| 157 | 157 | $this->messageClass = $messageClass; |
| 158 | 158 | } |
| 159 | 159 | |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | * @access public |
| 164 | 164 | * @return string message class to create instances from |
| 165 | 165 | */ |
| 166 | - public function getMessageClass(){
|
|
| 166 | + public function getMessageClass() {
|
|
| 167 | 167 | return $this->messageClass; |
| 168 | 168 | } |
| 169 | 169 | |
@@ -116,8 +116,7 @@ |
||
| 116 | 116 | $this->send($content); |
| 117 | 117 | try {
|
| 118 | 118 | $res = $this->receive(); |
| 119 | - } |
|
| 120 | - catch(\Exception $e){
|
|
| 119 | + } catch(\Exception $e){
|
|
| 121 | 120 | return NULL; |
| 122 | 121 | } |
| 123 | 122 | return $res; |
@@ -56,7 +56,6 @@ discard block |
||
| 56 | 56 | * sets the channel to send requests from the gateway |
| 57 | 57 | * |
| 58 | 58 | * @access public |
| 59 | - * @param \PEIP\INF\Channel\Channel $replyChannel The default channel to receive requests from the gateway |
|
| 60 | 59 | * @return |
| 61 | 60 | */ |
| 62 | 61 | public function setRequestChannel(\PEIP\INF\Channel\Channel $requestChannel){
|
@@ -109,7 +108,7 @@ discard block |
||
| 109 | 108 | * sends and receives a request/message through the gateway |
| 110 | 109 | * |
| 111 | 110 | * @access public |
| 112 | - * @param mixed $content the content/payload for the message to send |
|
| 111 | + * @param \Order $content the content/payload for the message to send |
|
| 113 | 112 | * @return mixed content/payload of the received message |
| 114 | 113 | */ |
| 115 | 114 | public function sendAndReceive($content){
|
@@ -33,10 +33,10 @@ |
||
| 33 | 33 | * Send a message, blocking until either the message is accepted or the |
| 34 | 34 | * specified timeout period elapses. |
| 35 | 35 | * |
| 36 | - * @param message the {@link Message} to send
|
|
| 37 | - * @param timeout the timeout in milliseconds |
|
| 36 | + * @param message \PEIP\INF\Message\Message {@link Message} to send
|
|
| 37 | + * @param timeout integer timeout in milliseconds |
|
| 38 | 38 | * |
| 39 | - * @return <code>true</code> if the message is sent successfully, |
|
| 39 | + * @return void if the message is sent successfully, |
|
| 40 | 40 | * <code>false</false> if the specified timeout period elapses or |
| 41 | 41 | * the send is interrupted |
| 42 | 42 | */ |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | * @implements \PEIP\INF\Base\Container, \PEIP\INF\Message\Message, \PEIP\INF\Base\Buildable |
| 21 | 21 | */ |
| 22 | 22 | |
| 23 | -use PEIP\Util\Test; |
|
| 23 | +use PEIP\Util\Test; |
|
| 24 | 24 | use PEIP\Base\GenericBuilder; |
| 25 | 25 | |
| 26 | 26 | class GenericMessage |
@@ -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 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @param mixed $content The content/payload of the message |
| 42 | 42 | * @param array|ArrayAccess $headers headers as key/value pairs |
| 43 | 43 | */ |
| 44 | - public function __construct($content, $headers = array()){
|
|
| 44 | + public function __construct($content, $headers = array()) {
|
|
| 45 | 45 | $this->doSetContent($content); |
| 46 | 46 | $this->doSetHeaders($headers); |
| 47 | 47 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * @access public |
| 54 | 54 | * @return |
| 55 | 55 | */ |
| 56 | - public function getContent(){
|
|
| 56 | + public function getContent() {
|
|
| 57 | 57 | return $this->content; |
| 58 | 58 | } |
| 59 | 59 | |
@@ -63,13 +63,13 @@ discard block |
||
| 63 | 63 | * @access protected |
| 64 | 64 | * @param mixed $content The content/payload of the message |
| 65 | 65 | */ |
| 66 | - protected function doSetContent($content){
|
|
| 66 | + protected function doSetContent($content) {
|
|
| 67 | 67 | $this->content = Test::castType($content, self::CONTENT_CAST_TYPE); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - protected function doSetHeaders($headers){
|
|
| 70 | + protected function doSetHeaders($headers) {
|
|
| 71 | 71 | $headers = Test::ensureArrayAccess($headers); |
| 72 | - if(is_array($headers)){
|
|
| 72 | + if (is_array($headers)) {
|
|
| 73 | 73 | $headers = new \ArrayObject($headers); |
| 74 | 74 | } |
| 75 | 75 | $this->headers = $headers; |
@@ -81,8 +81,8 @@ discard block |
||
| 81 | 81 | * @access public |
| 82 | 82 | * @return ArrayAccess ArrayAccess object of headers |
| 83 | 83 | */ |
| 84 | - public function getHeaders(){
|
|
| 85 | - return (array) $this->headers; |
|
| 84 | + public function getHeaders() {
|
|
| 85 | + return (array)$this->headers; |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | * @param string $name the name of the header |
| 93 | 93 | * @return mixed the value of the header |
| 94 | 94 | */ |
| 95 | - public function getHeader($name){
|
|
| 95 | + public function getHeader($name) {
|
|
| 96 | 96 | $name = (string)$name; |
| 97 | 97 | return isset($this->headers[$name]) ? $this->headers[$name] : NULL; |
| 98 | 98 | } |
@@ -105,8 +105,8 @@ discard block |
||
| 105 | 105 | * @param string $name the name of the header |
| 106 | 106 | * @return boolean wether the header has been successfully set |
| 107 | 107 | */ |
| 108 | - public function addHeader($name, $value){
|
|
| 109 | - if(!$this->hasHeader($name)){
|
|
| 108 | + public function addHeader($name, $value) {
|
|
| 109 | + if (!$this->hasHeader($name)) {
|
|
| 110 | 110 | $this->headers[$name] = $value; |
| 111 | 111 | return true; |
| 112 | 112 | } |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | * @param string $name the name of the header |
| 121 | 121 | * @return boolean wether the header is set |
| 122 | 122 | */ |
| 123 | - public function hasHeader($name){
|
|
| 123 | + public function hasHeader($name) {
|
|
| 124 | 124 | return isset($this->headers[$name]); |
| 125 | 125 | } |
| 126 | 126 | |
@@ -130,16 +130,16 @@ discard block |
||
| 130 | 130 | * @access public |
| 131 | 131 | * @return string content/payload of the message |
| 132 | 132 | */ |
| 133 | - public function __toString(){
|
|
| 133 | + public function __toString() {
|
|
| 134 | 134 | $res = false; |
| 135 | 135 | try {
|
| 136 | 136 | $res = (string)$this->getContent(); |
| 137 | 137 | } |
| 138 | - catch(\Exception $e){
|
|
| 138 | + catch (\Exception $e) {
|
|
| 139 | 139 | try {
|
| 140 | 140 | $res = get_class($this->getContent()); |
| 141 | 141 | } |
| 142 | - catch(\Exception $e){
|
|
| 142 | + catch (\Exception $e) {
|
|
| 143 | 143 | |
| 144 | 144 | } |
| 145 | 145 | } |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | * @param array $arguments argumends for the constructor |
| 160 | 160 | * @return GenericMessage new class instance |
| 161 | 161 | */ |
| 162 | - public static function build(array $arguments = array()){
|
|
| 162 | + public static function build(array $arguments = array()) {
|
|
| 163 | 163 | return GenericBuilder::getInstance(__CLASS__)->build($arguments); |
| 164 | 164 | } |
| 165 | 165 | } |
| 166 | 166 | \ No newline at end of file |
@@ -134,12 +134,10 @@ |
||
| 134 | 134 | $res = false; |
| 135 | 135 | try {
|
| 136 | 136 | $res = (string)$this->getContent(); |
| 137 | - } |
|
| 138 | - catch(\Exception $e){
|
|
| 137 | + } catch(\Exception $e){
|
|
| 139 | 138 | try {
|
| 140 | 139 | $res = get_class($this->getContent()); |
| 141 | - } |
|
| 142 | - catch(\Exception $e){
|
|
| 140 | + } catch(\Exception $e){
|
|
| 143 | 141 | |
| 144 | 142 | } |
| 145 | 143 | } |
@@ -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 | } |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | protected function getMessage($object){
|
| 18 | 18 | if($this->channel instanceof \PEIP\INF\Channel\SubscribableChannel){
|
| 19 | 19 | return $object; |
| 20 | - }else{
|
|
| 20 | + } else{
|
|
| 21 | 21 | return $object->getContent()->receive(); |
| 22 | 22 | } |
| 23 | 23 | } |
@@ -24,8 +24,8 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | 26 | |
| 27 | -use PEIP\Dispatcher\Dispatcher; |
|
| 28 | -use PEIP\Event\Event; |
|
| 27 | +use PEIP\Dispatcher\Dispatcher; |
|
| 28 | +use PEIP\Event\Event; |
|
| 29 | 29 | use PEIP\Util\Test; |
| 30 | 30 | |
| 31 | 31 | class Pipe |
@@ -188,7 +188,7 @@ |
||
| 188 | 188 | |
| 189 | 189 | /** |
| 190 | 190 | * @access protected |
| 191 | - * @param $commandName |
|
| 191 | + * @param string $commandName |
|
| 192 | 192 | * @param $callable |
| 193 | 193 | * @return |
| 194 | 194 | */ |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * @param $name |
| 65 | 65 | * @return |
| 66 | 66 | */ |
| 67 | - public function setName($name){
|
|
| 67 | + public function setName($name) {
|
|
| 68 | 68 | $this->name = $name; |
| 69 | 69 | } |
| 70 | 70 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | * @access public |
| 74 | 74 | * @return |
| 75 | 75 | */ |
| 76 | - public function getName(){
|
|
| 76 | + public function getName() {
|
|
| 77 | 77 | return $this->name; |
| 78 | 78 | } |
| 79 | 79 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | * @param $timeout |
| 85 | 85 | * @return |
| 86 | 86 | */ |
| 87 | - public function send(\PEIP\INF\Message\Message $message, $timeout = -1){
|
|
| 87 | + public function send(\PEIP\INF\Message\Message $message, $timeout = -1) {
|
|
| 88 | 88 | return $this->handle($message); |
| 89 | 89 | } |
| 90 | 90 | |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | * @param $message |
| 95 | 95 | * @return |
| 96 | 96 | */ |
| 97 | - protected function doSend(\PEIP\INF\Message\Message $message){
|
|
| 97 | + protected function doSend(\PEIP\INF\Message\Message $message) {
|
|
| 98 | 98 | $this->doFireEvent(self::EVENT_PRE_PUBLISH, array(self::HEADER_MESSAGE=>$message)); |
| 99 | 99 | $this->getMessageDispatcher()->notify($message); |
| 100 | 100 | $this->doFireEvent(self::EVENT_POST_PUBLISH, array(self::HEADER_MESSAGE=>$message)); |
@@ -107,12 +107,12 @@ discard block |
||
| 107 | 107 | * @param $content |
| 108 | 108 | * @return |
| 109 | 109 | */ |
| 110 | - protected function replyMessage($message){
|
|
| 110 | + protected function replyMessage($message) {
|
|
| 111 | 111 | $message = $this->ensureMessage($message); |
| 112 | 112 | //if(\PEIP\Util\Test::assertMessage($message)){
|
| 113 | - if($this->getOutputChannel()){
|
|
| 113 | + if ($this->getOutputChannel()) {
|
|
| 114 | 114 | $this->getOutputChannel()->send($message); |
| 115 | - }else{
|
|
| 115 | + }else {
|
|
| 116 | 116 | $this->doSend($message); |
| 117 | 117 | } |
| 118 | 118 | //} |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | * @param $message |
| 125 | 125 | * @return |
| 126 | 126 | */ |
| 127 | - protected function doReply(\PEIP\INF\Message\Message $message){
|
|
| 127 | + protected function doReply(\PEIP\INF\Message\Message $message) {
|
|
| 128 | 128 | $this->replyMessage($message); |
| 129 | 129 | } |
| 130 | 130 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | * @param $handler |
| 135 | 135 | * @return |
| 136 | 136 | */ |
| 137 | - public function subscribe($handler){
|
|
| 137 | + public function subscribe($handler) {
|
|
| 138 | 138 | Test::ensureHandler($handler); |
| 139 | 139 | $this->getMessageDispatcher()->connect($handler); |
| 140 | 140 | $this->doFireEvent(self::EVENT_SUBSCRIBE, array(self::HEADER_SUBSCRIBER=>$handler)); |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | * @param $handler e |
| 147 | 147 | * @return |
| 148 | 148 | */ |
| 149 | - public function unsubscribe($handler){
|
|
| 149 | + public function unsubscribe($handler) {
|
|
| 150 | 150 | Test::ensureHandler($handler); |
| 151 | 151 | $this->getMessageDispatcher()->disconnect($handler); |
| 152 | 152 | $this->doFireEvent( |
@@ -164,9 +164,9 @@ discard block |
||
| 164 | 164 | * @param $transferListeners |
| 165 | 165 | * @return |
| 166 | 166 | */ |
| 167 | - public function setMessageDispatcher(\PEIP\INF\Dispatcher\Dispatcher $dispatcher, $transferListeners = true){
|
|
| 168 | - if(isset($this->dispatcher) && $transferListeners){
|
|
| 169 | - foreach($this->dispatcher->getListeners() as $listener){
|
|
| 167 | + public function setMessageDispatcher(\PEIP\INF\Dispatcher\Dispatcher $dispatcher, $transferListeners = true) {
|
|
| 168 | + if (isset($this->dispatcher) && $transferListeners) {
|
|
| 169 | + foreach ($this->dispatcher->getListeners() as $listener) {
|
|
| 170 | 170 | $dispatcher->connect($listener); |
| 171 | 171 | $this->dispatcher->disconnect($listener); |
| 172 | 172 | } |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | * @access public |
| 181 | 181 | * @return |
| 182 | 182 | */ |
| 183 | - public function getMessageDispatcher(){
|
|
| 183 | + public function getMessageDispatcher() {
|
|
| 184 | 184 | $defaultDispatcher = self::DEFAULT_CLASS_MESSAGE_DISPATCHER; |
| 185 | 185 | return isset($this->dispatcher) ? $this->dispatcher : $this->dispatcher = new $defaultDispatcher; |
| 186 | 186 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | * @param $callable |
| 193 | 193 | * @return |
| 194 | 194 | */ |
| 195 | - protected function registerCommand($commandName, $callable){
|
|
| 195 | + protected function registerCommand($commandName, $callable) {
|
|
| 196 | 196 | $this->commands[$commandName] = $callable; |
| 197 | 197 | } |
| 198 | 198 | |
@@ -202,10 +202,10 @@ discard block |
||
| 202 | 202 | * @param $cmdMessage |
| 203 | 203 | * @return |
| 204 | 204 | */ |
| 205 | - public function command(\PEIP\INF\Message\Message $cmdMessage){
|
|
| 205 | + public function command(\PEIP\INF\Message\Message $cmdMessage) {
|
|
| 206 | 206 | $this->doFireEvent(self::EVENT_PRE_COMMAND, array(self::HEADER_MESSAGE=>$cmdMessage)); |
| 207 | 207 | $commandName = trim((string)$cmdMessage->getHeader('COMMAND'));
|
| 208 | - if($commandName != '' && array_key_exists($commandName, $this->commands)){
|
|
| 208 | + if ($commandName != '' && array_key_exists($commandName, $this->commands)) {
|
|
| 209 | 209 | call_user_func($this->commands[$commandName], $cmdMessage->getContent()); |
| 210 | 210 | } |
| 211 | 211 | $this->doFireEvent(self::EVENT_POST_COMMAND, array(self::HEADER_MESSAGE=>$cmdMessage)); |
@@ -112,7 +112,7 @@ |
||
| 112 | 112 | //if(\PEIP\Util\Test::assertMessage($message)){
|
| 113 | 113 | if($this->getOutputChannel()){
|
| 114 | 114 | $this->getOutputChannel()->send($message); |
| 115 | - }else{
|
|
| 115 | + } else{
|
|
| 116 | 116 | $this->doSend($message); |
| 117 | 117 | } |
| 118 | 118 | //} |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | * |
| 218 | 218 | * @access protected |
| 219 | 219 | * @param object $config configuration object to create arguments from. |
| 220 | - * @return mixed build arguments |
|
| 220 | + * @return \PEIP\INF\Channel\Channel[] build arguments |
|
| 221 | 221 | */ |
| 222 | 222 | protected function getReplyHandlerArguments($config){
|
| 223 | 223 | $args = array( |
@@ -262,7 +262,8 @@ discard block |
||
| 262 | 262 | * |
| 263 | 263 | * @access protected |
| 264 | 264 | * @param string the configuration type ofthe channel (e.g.: 'reply', 'request') |
| 265 | - * @param object $config configuration object to return channel from. |
|
| 265 | + * @param object $config configuration object to return channel from. |
|
| 266 | + * @param string $type |
|
| 266 | 267 | * @return \PEIP\INF\Channel\Channel reply-channel |
| 267 | 268 | */ |
| 268 | 269 | public function doGetChannel($type, $config){
|
@@ -11,11 +11,11 @@ |
||
| 11 | 11 | * |
| 12 | 12 | * @author timo |
| 13 | 13 | */ |
| 14 | -use PEIP\Context\XMLContext; |
|
| 15 | -use PEIP\Channel\PollableChannel; |
|
| 16 | -use PEIP\Channel\PublishSubscribeChannel; |
|
| 17 | -use PEIP\Gateway\SimpleMessagingGateway; |
|
| 18 | -use PEIP\Listener\Wiretap; |
|
| 14 | +use PEIP\Context\XMLContext; |
|
| 15 | +use PEIP\Channel\PollableChannel; |
|
| 16 | +use PEIP\Channel\PublishSubscribeChannel; |
|
| 17 | +use PEIP\Gateway\SimpleMessagingGateway; |
|
| 18 | +use PEIP\Listener\Wiretap; |
|
| 19 | 19 | use PEIP\Service\ServiceActivator; |
| 20 | 20 | |
| 21 | 21 | class BasePlugin extends \PEIP\ABS\Context\ContextPlugin {
|
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | * @param object $config configuration object for the pollable channel. |
| 47 | 47 | * @return \PEIP\INF\Channel\Channel the created pollable channel instance |
| 48 | 48 | */ |
| 49 | - public function createChannel($config){
|
|
| 49 | + public function createChannel($config) {
|
|
| 50 | 50 | return $this->doCreateChannel($config, 'PollableChannel'); |
| 51 | 51 | } |
| 52 | 52 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * @param object $config configuration object for the subscribable channel. |
| 59 | 59 | * @return \PEIP\INF\Channel\Channel the created subscribable channel instance |
| 60 | 60 | */ |
| 61 | - public function createSubscribableChannel($config){
|
|
| 61 | + public function createSubscribableChannel($config) {
|
|
| 62 | 62 | return $this->doCreateChannel($config, 'PublishSubscribeChannel'); |
| 63 | 63 | } |
| 64 | 64 | |
@@ -71,9 +71,9 @@ discard block |
||
| 71 | 71 | * @param $additionalArguments additional arguments for the channel constructor (without first arg = id) |
| 72 | 72 | * @return \PEIP\INF\Channel\Channel the created channel instance |
| 73 | 73 | */ |
| 74 | - public function doCreateChannel($config, $defaultChannelClass, array $additionalArguments = array()){
|
|
| 74 | + public function doCreateChannel($config, $defaultChannelClass, array $additionalArguments = array()) {
|
|
| 75 | 75 | $id = (string)$config['id']; |
| 76 | - if($id != ''){
|
|
| 76 | + if ($id != '') {
|
|
| 77 | 77 | array_unshift($additionalArguments, $id); |
| 78 | 78 | $channel = $this->buildAndModify($config, $additionalArguments, $defaultChannelClass); |
| 79 | 79 | //$this->channelRegistry->register($channel); |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * @param string $defaultClass the class to use if none is set in config. |
| 92 | 92 | * @return object the gateway instance |
| 93 | 93 | */ |
| 94 | - public function createGateway($config, $defaultClass = false){
|
|
| 94 | + public function createGateway($config, $defaultClass = false) {
|
|
| 95 | 95 | $args = array( |
| 96 | 96 | $this->getRequestChannel($config), |
| 97 | 97 | $this->getReplyChannel($config) |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | * @param string $defaultClass the class to use if none is set in config. |
| 116 | 116 | * @return object the router instance |
| 117 | 117 | */ |
| 118 | - public function createRouter($config, $defaultClass = false){
|
|
| 118 | + public function createRouter($config, $defaultClass = false) {
|
|
| 119 | 119 | $resolver = $config['channel_resolver'] ? (string)$config['channel_resolver'] : $this->channelRegistry; |
| 120 | 120 | return $this->buildAndModify($config, array( |
| 121 | 121 | $resolver, |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | * @param object $config configuration object for the splitter. |
| 133 | 133 | * @return object the splitter instance |
| 134 | 134 | */ |
| 135 | - public function createSplitter($config){
|
|
| 135 | + public function createSplitter($config) {
|
|
| 136 | 136 | return $this->createReplyMessageHandler($config); |
| 137 | 137 | } |
| 138 | 138 | |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | * @param object $config configuration object for the transformer. |
| 146 | 146 | * @return object the transformer instance |
| 147 | 147 | */ |
| 148 | - public function createTransformer($config){
|
|
| 148 | + public function createTransformer($config) {
|
|
| 149 | 149 | return $this->createReplyMessageHandler($config); |
| 150 | 150 | } |
| 151 | 151 | |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * @param object $config configuration object for the aggregator. |
| 159 | 159 | * @return object the aggregator instance |
| 160 | 160 | */ |
| 161 | - public function createAggregator($config){
|
|
| 161 | + public function createAggregator($config) {
|
|
| 162 | 162 | return $this->createReplyMessageHandler($config); |
| 163 | 163 | } |
| 164 | 164 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | * @param object $config configuration object for the wiretap. |
| 172 | 172 | * @return object the wiretap instance |
| 173 | 173 | */ |
| 174 | - public function createWiretap($config){
|
|
| 174 | + public function createWiretap($config) {
|
|
| 175 | 175 | return $this->createReplyMessageHandler($config, 'Wiretap'); |
| 176 | 176 | } |
| 177 | 177 | |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | * @param string $defaultClass the class to use if none is set in config. |
| 185 | 185 | * @return object the reply-message-handler instance |
| 186 | 186 | */ |
| 187 | - public function createReplyMessageHandler($config, $defaultClass = false){
|
|
| 187 | + public function createReplyMessageHandler($config, $defaultClass = false) {
|
|
| 188 | 188 | return $this->buildAndModify($config, $this->getReplyHandlerArguments($config), $defaultClass); |
| 189 | 189 | } |
| 190 | 190 | |
@@ -197,12 +197,12 @@ discard block |
||
| 197 | 197 | * @param string $defaultClass the class to use if none is set in config. |
| 198 | 198 | * @return object the service-activator instance |
| 199 | 199 | */ |
| 200 | - public function createServiceActivator($config, $defaultClass = false){
|
|
| 200 | + public function createServiceActivator($config, $defaultClass = false) {
|
|
| 201 | 201 | $method = (string)$config['method']; |
| 202 | 202 | $service = $this->context->getServiceProvider()->provideService((string)$config['ref']); |
| 203 | - if($method && $service){
|
|
| 203 | + if ($method && $service) {
|
|
| 204 | 204 | $args = $this->getReplyHandlerArguments($config); |
| 205 | - array_unshift($args,array( |
|
| 205 | + array_unshift($args, array( |
|
| 206 | 206 | $service, |
| 207 | 207 | $method |
| 208 | 208 | )); |
@@ -219,12 +219,12 @@ discard block |
||
| 219 | 219 | * @param object $config configuration object to create arguments from. |
| 220 | 220 | * @return mixed build arguments |
| 221 | 221 | */ |
| 222 | - protected function getReplyHandlerArguments($config){
|
|
| 222 | + protected function getReplyHandlerArguments($config) {
|
|
| 223 | 223 | $args = array( |
| 224 | 224 | $this->doGetChannel('input', $config),
|
| 225 | 225 | $this->doGetChannel('output', $config)
|
| 226 | 226 | ); |
| 227 | - if($args[0] == NULL){
|
|
| 227 | + if ($args[0] == NULL) {
|
|
| 228 | 228 | throw new \RuntimeException('Could not receive input channel.');
|
| 229 | 229 | } |
| 230 | 230 | return $args; |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | * @param object $config configuration object to return request-channel from. |
| 240 | 240 | * @return \PEIP\INF\Channel\Channel request-channel |
| 241 | 241 | */ |
| 242 | - protected function getRequestChannel($config){
|
|
| 242 | + protected function getRequestChannel($config) {
|
|
| 243 | 243 | return $this->doGetChannel('request', $config);
|
| 244 | 244 | } |
| 245 | 245 | |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | * @param object $config configuration object to return reply-channel from. |
| 253 | 253 | * @return \PEIP\INF\Channel\Channel reply-channel |
| 254 | 254 | */ |
| 255 | - protected function getReplyChannel($config){
|
|
| 255 | + protected function getReplyChannel($config) {
|
|
| 256 | 256 | return $this->doGetChannel('reply', $config);
|
| 257 | 257 | } |
| 258 | 258 | |
@@ -265,15 +265,15 @@ discard block |
||
| 265 | 265 | * @param object $config configuration object to return channel from. |
| 266 | 266 | * @return \PEIP\INF\Channel\Channel reply-channel |
| 267 | 267 | */ |
| 268 | - public function doGetChannel($type, $config){
|
|
| 268 | + public function doGetChannel($type, $config) {
|
|
| 269 | 269 | $channelName = $config[$type."_channel"] |
| 270 | 270 | ? $config[$type."_channel"] |
| 271 | 271 | : $config["default_".$type."_channel"]; |
| 272 | 272 | return $this->context->getServiceProvider()->provideService(trim((string)$channelName)); |
| 273 | - $channel = $this->services[trim((string)$channelName)]; |
|
| 274 | - if($channel instanceof \PEIP\INF\Channel\Channel){
|
|
| 273 | + $channel = $this->services[trim((string)$channelName)]; |
|
| 274 | + if ($channel instanceof \PEIP\INF\Channel\Channel) {
|
|
| 275 | 275 | return $channel; |
| 276 | - }else{
|
|
| 276 | + }else {
|
|
| 277 | 277 | return NULL; |
| 278 | 278 | } |
| 279 | 279 | } |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | protected function getMessage($object){
|
| 18 | 18 | if($this->channel instanceof \PEIP\INF\Channel\SubscribableChannel){
|
| 19 | 19 | return $object; |
| 20 | - }else{
|
|
| 20 | + } else{
|
|
| 21 | 21 | return $object->getContent()->receive(); |
| 22 | 22 | } |
| 23 | 23 | } |