@@ -3,22 +3,22 @@ |
||
| 3 | 3 | |
| 4 | 4 | class Waiter { |
| 5 | 5 | |
| 6 | - protected $orders; |
|
| 6 | + protected $orders; |
|
| 7 | 7 | |
| 8 | - public function prepareDelivery(array $drinks){ |
|
| 9 | - echo PEIP_LINE_SEPARATOR.'Waiter: prepareDelivery: #'.$drinks[0]->getOrderNumber(); |
|
| 10 | - return new Delivery($drinks); |
|
| 11 | - } |
|
| 8 | + public function prepareDelivery(array $drinks){ |
|
| 9 | + echo PEIP_LINE_SEPARATOR.'Waiter: prepareDelivery: #'.$drinks[0]->getOrderNumber(); |
|
| 10 | + return new Delivery($drinks); |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | 13 | |
| 14 | - public function receiveOrder(Order $order){ |
|
| 15 | - echo PEIP_LINE_SEPARATOR.'Waiter: receiveOrder'; |
|
| 16 | - $this->orders[$order->getOrderNumber()] = $order; |
|
| 17 | - } |
|
| 14 | + public function receiveOrder(Order $order){ |
|
| 15 | + echo PEIP_LINE_SEPARATOR.'Waiter: receiveOrder'; |
|
| 16 | + $this->orders[$order->getOrderNumber()] = $order; |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - public function getOrder($nr){ |
|
| 20 | - return $this->orders[$nr]; |
|
| 21 | - } |
|
| 19 | + public function getOrder($nr){ |
|
| 20 | + return $this->orders[$nr]; |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | 23 | |
| 24 | 24 | } |
@@ -32,11 +32,11 @@ |
||
| 32 | 32 | protected $services = array(); |
| 33 | 33 | |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Constructor. |
|
| 37 | - * |
|
| 38 | - * @param array $parameters An array of parameters |
|
| 39 | - */ |
|
| 35 | + /** |
|
| 36 | + * Constructor. |
|
| 37 | + * |
|
| 38 | + * @param array $parameters An array of parameters |
|
| 39 | + */ |
|
| 40 | 40 | |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -31,13 +31,13 @@ |
||
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | - * Calls a method on a service (registered as a callable) with |
|
| 35 | - * content/payload of given message as argument. |
|
| 36 | - * |
|
| 37 | - * @access protected |
|
| 38 | - * @param \PEIP\INF\Message\Message $message message to call the service with it�s content/payload |
|
| 39 | - * @return mixed result of calling the registered service callable with message content/payload |
|
| 40 | - */ |
|
| 34 | + * Calls a method on a service (registered as a callable) with |
|
| 35 | + * content/payload of given message as argument. |
|
| 36 | + * |
|
| 37 | + * @access protected |
|
| 38 | + * @param \PEIP\INF\Message\Message $message message to call the service with it�s content/payload |
|
| 39 | + * @return mixed result of calling the registered service callable with message content/payload |
|
| 40 | + */ |
|
| 41 | 41 | protected function callService(\PEIP\INF\Message\Message $message){
|
| 42 | 42 | $res = NULL; |
| 43 | 43 | if(is_callable($this->serviceCallable)){
|
@@ -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 |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | ); |
| 90 | 90 | $plugin = new BasePlugin(); |
| 91 | 91 | foreach($builders as $nodeName => $method){
|
| 92 | - $this->registerNodeBuilder($nodeName, array($this, $method)); |
|
| 92 | + $this->registerNodeBuilder($nodeName, array($this, $method)); |
|
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
@@ -209,11 +209,11 @@ |
||
| 209 | 209 | */ |
| 210 | 210 | protected static function doNotify(array $listeners, $subject){
|
| 211 | 211 | foreach($listeners as $listener){
|
| 212 | - if($listener instanceof \PEIP\INF\Handler\Handler){
|
|
| 212 | + if($listener instanceof \PEIP\INF\Handler\Handler){
|
|
| 213 | 213 | $listener->handle($subject); |
| 214 | - }elseif(is_callable($listener)){
|
|
| 215 | - call_user_func($listener, $subject); |
|
| 216 | - } |
|
| 214 | + }elseif(is_callable($listener)){
|
|
| 215 | + call_user_func($listener, $subject); |
|
| 216 | + } |
|
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | 219 | |
@@ -32,9 +32,9 @@ discard block |
||
| 32 | 32 | $this->getListeners( |
| 33 | 33 | $name, |
| 34 | 34 | $object |
| 35 | - ), |
|
| 36 | - $object->getContent() |
|
| 37 | - ); |
|
| 35 | + ), |
|
| 36 | + $object->getContent() |
|
| 37 | + ); |
|
| 38 | 38 | }else{
|
| 39 | 39 | throw new \InvalidArgumentException('instance of \PEIP\INF\Event\Event must contain subject');
|
| 40 | 40 | } |
@@ -43,18 +43,18 @@ discard block |
||
| 43 | 43 | } |
| 44 | 44 | } //put your code here |
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Creates an event-object with given object as content/subject and notifies |
|
| 48 | - * all registers listeners of the event. |
|
| 49 | - * |
|
| 50 | - * @access public |
|
| 51 | - * @param string $name name of the event |
|
| 52 | - * @param object $object the subject of the event |
|
| 53 | - * @param array $headers headers of the event-object as key/value pairs |
|
| 54 | - * @param string $eventClass event-class to create instances from |
|
| 55 | - * @return |
|
| 56 | - * @see EventBuilder |
|
| 57 | - */ |
|
| 46 | + /** |
|
| 47 | + * Creates an event-object with given object as content/subject and notifies |
|
| 48 | + * all registers listeners of the event. |
|
| 49 | + * |
|
| 50 | + * @access public |
|
| 51 | + * @param string $name name of the event |
|
| 52 | + * @param object $object the subject of the event |
|
| 53 | + * @param array $headers headers of the event-object as key/value pairs |
|
| 54 | + * @param string $eventClass event-class to create instances from |
|
| 55 | + * @return |
|
| 56 | + * @see EventBuilder |
|
| 57 | + */ |
|
| 58 | 58 | public function buildAndNotify($name, $object, array $headers = array(), $eventClass = false, $type = false){
|
| 59 | 59 | if(!$this->hasListeners($name, ($object))){
|
| 60 | 60 | return false; |
@@ -67,9 +67,9 @@ discard block |
||
| 67 | 67 | Reflection_Pool::getInstance( |
| 68 | 68 | $object->getContent() |
| 69 | 69 | ) |
| 70 | - ), |
|
| 71 | - $object |
|
| 72 | - ); |
|
| 70 | + ), |
|
| 71 | + $object |
|
| 72 | + ); |
|
| 73 | 73 | }else{
|
| 74 | 74 | throw new \InvalidArgumentException('instance of \PEIP\INF\Event\Event must contain subject');
|
| 75 | 75 | } |
@@ -78,18 +78,18 @@ discard block |
||
| 78 | 78 | } |
| 79 | 79 | } //put your code here |
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * Creates an event-object with given object as content/subject and notifies |
|
| 83 | - * all registers listeners of the event. |
|
| 84 | - * |
|
| 85 | - * @access public |
|
| 86 | - * @param string $name name of the event |
|
| 87 | - * @param object $object the subject of the event |
|
| 88 | - * @param array $headers headers of the event-object as key/value pairs |
|
| 89 | - * @param string $eventClass event-class to create instances from |
|
| 90 | - * @return |
|
| 91 | - * @see EventBuilder |
|
| 92 | - */ |
|
| 81 | + /** |
|
| 82 | + * Creates an event-object with given object as content/subject and notifies |
|
| 83 | + * all registers listeners of the event. |
|
| 84 | + * |
|
| 85 | + * @access public |
|
| 86 | + * @param string $name name of the event |
|
| 87 | + * @param object $object the subject of the event |
|
| 88 | + * @param array $headers headers of the event-object as key/value pairs |
|
| 89 | + * @param string $eventClass event-class to create instances from |
|
| 90 | + * @return |
|
| 91 | + * @see EventBuilder |
|
| 92 | + */ |
|
| 93 | 93 | public function buildAndNotify($name, $object, array $headers = array(), $eventClass = false, $type = false){
|
| 94 | 94 | if(!$this->hasListeners($name, ($object))){
|
| 95 | 95 | return false; |
@@ -60,9 +60,9 @@ |
||
| 60 | 60 | */ |
| 61 | 61 | protected static function doNotifyUntil(array $listeners, $subject){
|
| 62 | 62 | foreach ($listeners as $listener){
|
| 63 | - if (self::doNotifyOne($listener, $subject)){
|
|
| 63 | + if (self::doNotifyOne($listener, $subject)){
|
|
| 64 | 64 | return $listener; |
| 65 | - } |
|
| 65 | + } |
|
| 66 | 66 | } |
| 67 | 67 | return NULL; |
| 68 | 68 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | public function connect($name, $listener){
|
| 48 | 48 | Test::ensureHandler($listener); |
| 49 | 49 | if (!$this->hasListeners($name)){
|
| 50 | - $this->listeners[$name] = array(); |
|
| 50 | + $this->listeners[$name] = array(); |
|
| 51 | 51 | } |
| 52 | 52 | $this->listeners[$name][] = $listener; |
| 53 | 53 | return true; |
@@ -67,10 +67,10 @@ discard block |
||
| 67 | 67 | } |
| 68 | 68 | $res = false; |
| 69 | 69 | foreach ($this->listeners[$name] as $i => $callable){
|
| 70 | - if ($listener === $callable){
|
|
| 70 | + if ($listener === $callable){
|
|
| 71 | 71 | unset($this->listeners[$name][$i]); |
| 72 | 72 | $res = true; |
| 73 | - } |
|
| 73 | + } |
|
| 74 | 74 | } |
| 75 | 75 | return $res; |
| 76 | 76 | } |