Advertisement
fruffl

Link Signal-Slot

Jan 26th, 2013
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.79 KB | None | 0 0
  1.     class bar extends \ILLI\Net\Message {}
  2.     class foo extends \ILLI\Net\Message {}
  3.     class bob extends \ILLI\Net\Message {}
  4.     class baz extends \ILLI\Core\StaticObject
  5.     {
  6.         protected static $__autoConfig = ['username'];
  7.         protected static $username = NULL;
  8.         public static function reseiveMyWorld($property, $value)
  9.         {
  10.             return static::aspectable(__FUNCTION__, get_defined_vars(), function($property, $value)
  11.             {
  12.                 static::$baz = [__METHOD__ => get_defined_vars()];
  13.                 return get_defined_vars();
  14.             });
  15.         }
  16.         public static function aspectableSetUsername($value)
  17.         {
  18.             static::$username = $value;
  19.         }
  20.     }
  21.    
  22.     $foo = new foo;
  23.     $bar = new bar;
  24.     $bob = new bob;
  25.    
  26.     baz::construct();
  27.     baz::registerSignal('aspectableSetUsername', baz::T_SIGNAL_EMIT_EVENT_INIT, 499, [$bob, 'propertySet']);
  28.    
  29.         $foo->registerSignal('aspectableSetUsername', bar::T_SIGNAL_EMIT_EVENT_INIT, 500, [$bar, 'propertySet']);
  30.         $foo->registerSignal('propertySet', bar::T_SIGNAL_EMIT_EVENT_INIT, 500, [$bob, 'propertySet']);
  31.    
  32.         $foo->scheme    = 'http';
  33.         $foo->host  = 'localfrost';
  34.         $foo->username  = 'fruffl';
  35.         $foo->password  = '12345';
  36.        
  37.     baz::propertySet('username', 'foooooooooooooooo');
  38.    
  39.     var_dump($foo->propertyCompact(['username', 'host']));
  40.     var_dump($bar->propertyCompact(['username', 'host']));
  41.     var_dump($bob->propertyCompact(['username', 'host']));
  42.     var_dump(baz::propertyCompact(['username']));
  43.  
  44.  
  45. /*
  46. array(2) {
  47.   ["username"]=>
  48.   string(6) "fruffl"
  49.   ["host"]=>
  50.   string(10) "localfrost"
  51. }
  52. array(2) {
  53.   ["username"]=>
  54.   string(6) "fruffl"
  55.   ["host"]=>
  56.   string(9) "localhost"
  57. }
  58. array(2) {
  59.   ["username"]=>
  60.   string(17) "foooooooooooooooo"
  61.   ["host"]=>
  62.   string(10) "localfrost"
  63. }
  64. array(1) {
  65.   ["username"]=>
  66.   string(17) "foooooooooooooooo"
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement