@@ -16,13 +16,13 @@ discard block |
||
| 16 | 16 | use PEIP\Context\XMLContext; |
| 17 | 17 | |
| 18 | 18 | class ServiceFactory {
|
| 19 | - /** |
|
| 20 | - * Creates and initializes service instance from a given configuration. |
|
| 21 | - * |
|
| 22 | - * @access public |
|
| 23 | - * @param $config configuration of the service |
|
| 24 | - * @return object the initialized service instance |
|
| 25 | - */ |
|
| 19 | + /** |
|
| 20 | + * Creates and initializes service instance from a given configuration. |
|
| 21 | + * |
|
| 22 | + * @access public |
|
| 23 | + * @param $config configuration of the service |
|
| 24 | + * @return object the initialized service instance |
|
| 25 | + */ |
|
| 26 | 26 | public static function createService(array $config){
|
| 27 | 27 | $args = array(); |
| 28 | 28 | //build arguments for constructor |
@@ -35,15 +35,15 @@ discard block |
||
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | - * Builds an arbitrary service/object instance from a config-obect. |
|
| 39 | - * |
|
| 40 | - * @static |
|
| 41 | - * @access protected |
|
| 42 | - * @param object $config configuration object to build a service instance from. |
|
| 43 | - * @param array $arguments arguments for the service constructor |
|
| 44 | - * @param string $defaultClass class to create instance for if none is set in config |
|
| 45 | - * @return object build and modified srvice instance |
|
| 46 | - */ |
|
| 38 | + * Builds an arbitrary service/object instance from a config-obect. |
|
| 39 | + * |
|
| 40 | + * @static |
|
| 41 | + * @access protected |
|
| 42 | + * @param object $config configuration object to build a service instance from. |
|
| 43 | + * @param array $arguments arguments for the service constructor |
|
| 44 | + * @param string $defaultClass class to create instance for if none is set in config |
|
| 45 | + * @return object build and modified srvice instance |
|
| 46 | + */ |
|
| 47 | 47 | public static function doBuild($config, $arguments, $defaultClass = false){
|
| 48 | 48 | $cls = isset($config["class"]) ? trim((string)$config["class"]) : (string)$defaultClass; |
| 49 | 49 | if($cls != ''){
|
@@ -80,12 +80,12 @@ discard block |
||
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | - * Builds single argument (to call a method with later) from a config-obect. |
|
| 84 | - * |
|
| 85 | - * @access protected |
|
| 86 | - * @param object $config configuration object to create argument from. |
|
| 87 | - * @return mixed build argument |
|
| 88 | - */ |
|
| 83 | + * Builds single argument (to call a method with later) from a config-obect. |
|
| 84 | + * |
|
| 85 | + * @access protected |
|
| 86 | + * @param object $config configuration object to create argument from. |
|
| 87 | + * @return mixed build argument |
|
| 88 | + */ |
|
| 89 | 89 | protected function buildArg($config){
|
| 90 | 90 | if(trim((string)$config['value']) != ''){
|
| 91 | 91 | $arg = (string)$config['value']; |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | public static function buildAndModify(array $config, $arguments, $defaultClass = ""){
|
| 130 | 130 | if((isset($config["class"]) && "" != (string)$config["class"]) || $defaultClass !== ""){
|
| 131 | - $service = ServiceFactory::doBuild($config, $arguments, $defaultClass); |
|
| 131 | + $service = ServiceFactory::doBuild($config, $arguments, $defaultClass); |
|
| 132 | 132 | }else{
|
| 133 | 133 | throw new \RuntimeException('Could not create Service. no class or reference given.');
|
| 134 | 134 | } |
@@ -133,7 +133,7 @@ |
||
| 133 | 133 | * @param callable $callable a callable which creates instances for node-name |
| 134 | 134 | */ |
| 135 | 135 | public function registerNodeBuilder($nodeName, $callable){
|
| 136 | - return $this->getServiceProvider()->registerNodeBuilder($nodeName, $callable); |
|
| 136 | + return $this->getServiceProvider()->registerNodeBuilder($nodeName, $callable); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | public static function createFromFile($file){
|
| 101 | 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 | } |
@@ -571,7 +571,7 @@ discard block |
||
| 571 | 571 | $ref = trim((string)$config['ref']); |
| 572 | 572 | if($ref != ''){
|
| 573 | 573 | $service = $this->getService($ref); |
| 574 | - }else{
|
|
| 574 | + } else{
|
|
| 575 | 575 | $service = $this->createService($config); |
| 576 | 576 | } |
| 577 | 577 | return $service; |
@@ -591,7 +591,7 @@ discard block |
||
| 591 | 591 | protected static function getSetter($config){
|
| 592 | 592 | if($config['setter']){
|
| 593 | 593 | $setter = (string)$config['setter']; |
| 594 | - }elseif($config['name']){
|
|
| 594 | + } elseif($config['name']){
|
|
| 595 | 595 | $setter = 'set'.ucfirst((string)$config['name']); |
| 596 | 596 | } |
| 597 | 597 | return $setter; |
@@ -607,26 +607,26 @@ discard block |
||
| 607 | 607 | protected function buildArg($config){
|
| 608 | 608 | if(trim((string)$config['value']) != ''){
|
| 609 | 609 | $arg = (string)$config['value']; |
| 610 | - }elseif($config->getName() == 'value'){
|
|
| 610 | + } elseif($config->getName() == 'value'){
|
|
| 611 | 611 | $arg = (string)$config; |
| 612 | - }elseif($config->getName() == 'list'){
|
|
| 612 | + } elseif($config->getName() == 'list'){
|
|
| 613 | 613 | $arg = array(); |
| 614 | 614 | foreach($config->children() as $entry){
|
| 615 | 615 | if($entry->getName() == 'value'){
|
| 616 | 616 | if($entry['key']){
|
| 617 | 617 | $arg[(string)$entry['key']] = (string)$entry; |
| 618 | - }else{
|
|
| 618 | + } else{
|
|
| 619 | 619 | $arg[] = (string)$entry; |
| 620 | 620 | } |
| 621 | - }elseif($entry->getName() == 'service'){
|
|
| 621 | + } elseif($entry->getName() == 'service'){
|
|
| 622 | 622 | $arg[] = $this->provideService($entry); |
| 623 | 623 | } |
| 624 | 624 | } |
| 625 | - }elseif($config->getName() == 'service'){
|
|
| 625 | + } elseif($config->getName() == 'service'){
|
|
| 626 | 626 | $arg = $this->provideService($config); |
| 627 | - }elseif($config->list){
|
|
| 627 | + } elseif($config->list){
|
|
| 628 | 628 | $arg = $this->buildArg($config->list); |
| 629 | - }elseif($config->service){
|
|
| 629 | + } elseif($config->service){
|
|
| 630 | 630 | $arg = $this->buildArg($config->service); |
| 631 | 631 | } |
| 632 | 632 | return $arg; |
@@ -694,7 +694,7 @@ discard block |
||
| 694 | 694 | $channel = $this->services[trim((string)$channelName)]; |
| 695 | 695 | if($channel instanceof \PEIP\INF\Channel\Channel){
|
| 696 | 696 | return $channel; |
| 697 | - }else{
|
|
| 697 | + } else{
|
|
| 698 | 698 | return NULL; |
| 699 | 699 | } |
| 700 | 700 | } |
@@ -718,10 +718,10 @@ discard block |
||
| 718 | 718 | $constructor = (string)$config["constructor"]; |
| 719 | 719 | if($constructor != ''){
|
| 720 | 720 | $service = call_user_func_array(array($cls, $constructor), $arguments); |
| 721 | - }else{
|
|
| 721 | + } else{
|
|
| 722 | 722 | $service = self::build($cls, $arguments); |
| 723 | 723 | } |
| 724 | - }catch(\Exception $e){
|
|
| 724 | + } catch(\Exception $e){
|
|
| 725 | 725 | throw new \RuntimeException('Could not create Service "'.$cls.'" -> '.$e->getMessage());
|
| 726 | 726 | } |
| 727 | 727 | } |
@@ -49,10 +49,10 @@ |
||
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | - * @access public |
|
| 53 | - * @param $observer |
|
| 54 | - * @return |
|
| 55 | - */ |
|
| 52 | + * @access public |
|
| 53 | + * @param $observer |
|
| 54 | + * @return |
|
| 55 | + */ |
|
| 56 | 56 | public function addObserver(\PEIP\INF\Event\Observer $observer){
|
| 57 | 57 | $this->observers[] = $observer; |
| 58 | 58 | } |