Advertisement
fruffl

ILLI\System\Object.Pattern

Aug 20th, 2012
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.98 KB | None | 0 0
  1. <?PHP
  2.     /**
  3.      * ILLI
  4.      *
  5.      * @category   ILLI_System
  6.      * @package    ILLI
  7.      * @link       http://illi.be
  8.      * @license    http://l.illi.be
  9.      * @copyright  ILLI Conference
  10.      */
  11.     NAMESPACE ILLI\System;
  12.     USE Serializable;
  13.  
  14.     /**
  15.      * ILLI Object
  16.      *
  17.      * @category   ILLI_System
  18.      * @package    ILLI
  19.      * @subpackage System
  20.      * @namespace  ILLI\System
  21.      * @link       http://illi.be
  22.      * @license    http://l.illi.be
  23.      * @copyright  ILLI Conference
  24.      * @since      2.0.1
  25.      * @version    3.0.1
  26.      */
  27.     CLASS Object EXTENDS System
  28.     {
  29.         USE tSplHashRegister
  30.         {
  31.             tSplHashRegister_getCode        as getHashCode;
  32.             tSplHashRegister_getInstances       as getSplInstances;
  33.             tSplHashRegister_getSiblings        as getSplSiblingInstances;
  34.             tSplHashRegister___register     as __registerSpl;
  35.             tSplHashRegister___unregister       as __unregisterSpl;
  36.         }
  37.        
  38.         USE tAdapter
  39.         {
  40.             tAdapter_registerTrigger        as adapterRegisterTrigger;
  41.             tAdapter_registerTriggerMethod      as adapterRegisterTriggerMethod;
  42.             tAdapter_registerTriggerStaticMethod    as adapterRegisterTriggerStaticMethod;
  43.             tAdapter_registerTriggerClosure     as adapterRegisterTriggerClosure;
  44.             tAdapter_unregisterTrigger      as adapterUnregisterTrigger;
  45.             tAdapter_callAlias          as adapterCallAlias;
  46.             tAdapter_triggerExists          as adapterTriggerExists;
  47.         }
  48.        
  49.         USE tObserver
  50.         {
  51.             tObserver_registerEvent         as observerRegisterEvent;
  52.             tObserver_registerEventMethod       as observerRegisterEventMethod;
  53.             tObserver_registerEventStaticMethod as observerRegisterEventStaticMethod;
  54.             tObserver_registerEventClosure      as observerRegisterEventClosure;
  55.             tObserver_unregisterEvent       as observerUnregisterEvent;
  56.             tObserver_notify            as observerNotify;
  57.             tObserver_eventExists           as observerEventExists;
  58.         }
  59.        
  60.         USE tFilter
  61.         {
  62.             tFilter_registerEvent           as filterRegisterEvent;
  63.             tFilter_registerEventMethod     as filterRegisterEventMethod;
  64.             tFilter_registerEventStaticMethod   as filterRegisterEventStaticMethod;
  65.             tFilter_registerEventClosure        as filterRegisterEventClosure;
  66.             tFilter_unregisterTrigger       as filterUnregisterEvent;
  67.             tFilter_triggerExists           as filterTriggerExists;
  68.             tFilter_applyFilter         as filterApply;
  69.         }
  70.        
  71.         protected $__Collection = NULL;
  72.        
  73.         public function randomize($arg)
  74.         {
  75.             (TRUE === $this->adapterTriggerExists(__METHOD__))
  76.                 ? $this->adapterCallAlias(__METHOD__, $arg)
  77.                 : var_dump(__METHOD__.'->'.$arg);
  78.         }
  79.        
  80.         public function __set($index, $value)
  81.         {
  82.             $foo = $this->filterApply('args', __METHOD__, array('index' => $index, 'value' => $value));
  83.             $index = $foo['index'];
  84.             $value = $foo['value'];
  85.             $this->__Collection->offsetSet($index, $value);
  86.             $this->observerNotify(__METHOD__, $index, $value);
  87.         }
  88.        
  89.         public function __construct()
  90.         {
  91.             $this->__registerSpl();
  92.             $this->__Collection = new Collection;
  93.            
  94.             $this->observerRegisterEventMethod(__CLASS__.'::__set', 'ILLI\System\Object::randomize');
  95.             $this->filterRegisterEventMethod('args', __CLASS__.'::__set', 'ILLI\System\Foo::findex');
  96.             $this->filterRegisterEventMethod('args', __CLASS__.'::__set', 'ILLI\System\Foo::toUpper');
  97.             $this->adapterRegisterTriggerStaticMethod('\ILLI\System\Object::randomize', 'ILLI\System\Foo::bar');
  98.            
  99.            
  100.            
  101.            
  102.            
  103.             //throw new \Exception('Test!');
  104.             /*
  105.             \ILLI\Boot\ErrorHandler::config
  106.             (
  107.                 array
  108.                 (
  109.                     array
  110.                     (
  111.                         //'code' => E_ALL | E_PARSE | E_STRICT | E_DEPRECATED | E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE
  112.                         //'type' => 'Exception',
  113.                         'handler' => function($info) use ($self) { $self->errors[] = $info; }
  114.                     )
  115.                 )
  116.             );
  117.             \ILLI\Boot\ErrorHandler::handle(new \Exception('Test!'));
  118.             */
  119.             /*
  120.             \ILLI\Boot\ErrorHandler::config
  121.             (
  122.                 array
  123.                 (
  124.                     array
  125.                     (
  126.                         //'code' => E_ALL | E_PARSE | E_STRICT | E_DEPRECATED | E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE
  127.                         //'type' => 'Exception',
  128.                         'handler' => function($info) use ($self) { $self->errors[] = $info; }
  129.                     )
  130.                 )
  131.             );
  132.            
  133.             \ILLI\Boot\ErrorHandler::handle(new \Exception('Test!'));
  134.             */
  135.            
  136.         }
  137.     }
  138.  
  139.  
  140.     $foo = new \ILLI\System\UUID;
  141.     $foo->baz = 'bar';
  142.     var_dump($foo);
  143.  
  144. ?>
  145.  
  146.  
  147.  
  148. string(56) "ILLI\System\Foo::bar->***ILLI\System\Foo::findex->baz***"
  149. object(ILLI\System\UUID)#17 (12) {
  150.   ["__value":"ILLI\System\UUID":private]=>
  151.   string(36) "7155526a-6632-4e55-aa70-564231476c68"
  152.   ["__Collection":protected]=>
  153.   object(ILLI\System\Collection)#18 (6) {
  154.     ["__data":"ILLI\System\Collection":private]=>
  155.     array(1) {
  156.       ["***ILLI\System\Foo::findex->baz***"]=>
  157.       string(3) "BAR"
  158.     }
  159.     ["__offsets":"ILLI\System\Collection":private]=>
  160.     array(1) {
  161.       [0]=>
  162.       string(34) "***ILLI\System\Foo::findex->baz***"
  163.     }
  164.     ["__indexes":"ILLI\System\Collection":private]=>
  165.     array(1) {
  166.       ["***ILLI\System\Foo::findex->baz***"]=>
  167.       int(0)
  168.     }
  169.     ["__iteratorIndex":"ILLI\System\Collection":private]=>
  170.     int(0)
  171.     ["__lastOffsetUpdate":"ILLI\System\Collection":private]=>
  172.     string(34) "***ILLI\System\Foo::findex->baz***"
  173.     ["__lastOffsetInsert":"ILLI\System\Collection":private]=>
  174.     NULL
  175.   }
  176.   ["__splHashRegisterAddress":"ILLI\System\Object":private]=>
  177.   string(32) "000000001d37f67d0000000014691efe"
  178.   ["__adapterTracesEnabled":"ILLI\System\Object":private]=>
  179.   bool(false)
  180.   ["__adapterTraces":"ILLI\System\Object":private]=>
  181.   array(0) {
  182.   }
  183.   ["__adapters":protected]=>
  184.   array(1) {
  185.     ["ILLI\System\Object::randomize"]=>
  186.     object(ILLI\System\AdapterAlias)#27 (2) {
  187.       ["__TRIGGER":"ILLI\System\AdapterAlias":private]=>
  188.       object(ILLI\System\Method)#37 (3) {
  189.         ["__class":protected]=>
  190.         string(18) "ILLI\System\Object"
  191.         ["__function":protected]=>
  192.         string(9) "randomize"
  193.         ["__method":protected]=>
  194.         string(29) "ILLI\System\Object::randomize"
  195.       }
  196.       ["__ALIAS":"ILLI\System\AdapterAlias":private]=>
  197.       object(ILLI\System\InvokeStaticMethod)#36 (1) {
  198.         ["__callable":protected]=>
  199.         object(ILLI\System\Method)#40 (3) {
  200.           ["__class":protected]=>
  201.           string(15) "ILLI\System\Foo"
  202.           ["__function":protected]=>
  203.           string(3) "bar"
  204.           ["__method":protected]=>
  205.           string(20) "ILLI\System\Foo::bar"
  206.         }
  207.       }
  208.     }
  209.   }
  210.   ["__observerTracesEnabled":"ILLI\System\Object":private]=>
  211.   bool(false)
  212.   ["__observerTraces":"ILLI\System\Object":private]=>
  213.   array(0) {
  214.   }
  215.   ["__observers":protected]=>
  216.   array(1) {
  217.     ["ILLI\System\Object::__set"]=>
  218.     array(1) {
  219.       [0]=>
  220.       object(ILLI\System\InvokeMethod)#22 (1) {
  221.         ["__callable":protected]=>
  222.         object(ILLI\System\Method)#23 (3) {
  223.           ["__class":protected]=>
  224.           string(18) "ILLI\System\Object"
  225.           ["__function":protected]=>
  226.           string(9) "randomize"
  227.           ["__method":protected]=>
  228.           string(29) "ILLI\System\Object::randomize"
  229.         }
  230.       }
  231.     }
  232.   }
  233.   ["__filterTracesEnabled":"ILLI\System\Object":private]=>
  234.   bool(false)
  235.   ["__filterTraces":"ILLI\System\Object":private]=>
  236.   array(0) {
  237.   }
  238.   ["__filters":protected]=>
  239.   array(1) {
  240.     ["ILLI\System\Object::__set"]=>
  241.     array(2) {
  242.       [0]=>
  243.       object(ILLI\System\FilterAlias)#25 (3) {
  244.         ["__event":"ILLI\System\FilterAlias":private]=>
  245.         string(4) "args"
  246.         ["__TRIGGER":"ILLI\System\FilterAlias":private]=>
  247.         object(ILLI\System\Method)#28 (3) {
  248.           ["__class":protected]=>
  249.           string(18) "ILLI\System\Object"
  250.           ["__function":protected]=>
  251.           string(5) "__set"
  252.           ["__method":protected]=>
  253.           string(25) "ILLI\System\Object::__set"
  254.         }
  255.         ["__FILTER":"ILLI\System\FilterAlias":private]=>
  256.         object(ILLI\System\InvokeMethod)#29 (1) {
  257.           ["__callable":protected]=>
  258.           object(ILLI\System\Method)#30 (3) {
  259.             ["__class":protected]=>
  260.             string(15) "ILLI\System\Foo"
  261.             ["__function":protected]=>
  262.             string(6) "findex"
  263.             ["__method":protected]=>
  264.             string(23) "ILLI\System\Foo::findex"
  265.           }
  266.         }
  267.       }
  268.       [1]=>
  269.       object(ILLI\System\FilterAlias)#31 (3) {
  270.         ["__event":"ILLI\System\FilterAlias":private]=>
  271.         string(4) "args"
  272.         ["__TRIGGER":"ILLI\System\FilterAlias":private]=>
  273.         object(ILLI\System\Method)#32 (3) {
  274.           ["__class":protected]=>
  275.           string(18) "ILLI\System\Object"
  276.           ["__function":protected]=>
  277.           string(5) "__set"
  278.           ["__method":protected]=>
  279.           string(25) "ILLI\System\Object::__set"
  280.         }
  281.         ["__FILTER":"ILLI\System\FilterAlias":private]=>
  282.         object(ILLI\System\InvokeMethod)#33 (1) {
  283.           ["__callable":protected]=>
  284.           object(ILLI\System\Method)#34 (3) {
  285.             ["__class":protected]=>
  286.             string(15) "ILLI\System\Foo"
  287.             ["__function":protected]=>
  288.             string(7) "toUpper"
  289.             ["__method":protected]=>
  290.             string(24) "ILLI\System\Foo::toUpper"
  291.           }
  292.         }
  293.       }
  294.     }
  295.   }
  296. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement