Advertisement
fruffl

! Wrap Constructor !

Nov 29th, 2012
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.77 KB | None | 0 0
  1. <?PHP
  2.     /**
  3.      * ILLI
  4.      *
  5.      * @package ILLI
  6.      * @link    http://illi.be
  7.      * @license http://l.illi.be
  8.      * @copyright   ILLI Conference
  9.      */
  10.     NAMESPACE ILLI\Base;
  11.     USE ILLI\Base\tBase             AS tBase;
  12.     USE ILLI\Base\Component\Delegate\Hook\tAdapter  AS tAdapter;
  13.     USE ILLI\Base\Component\Delegate\Hook\tSignal   AS tSignal;
  14.  
  15.     /**
  16.      * Property Base...
  17.      *
  18.      * @package ILLI
  19.      * @subpackage  Base
  20.      * @link    http://illi.be
  21.      * @license http://l.illi.be
  22.      * @copyright   ILLI Conference
  23.      */
  24.     ABSTRACT CLASS aBase
  25.     {
  26.         use tBase;
  27.        
  28.         USE tAdapter
  29.         {
  30.             Base_Component_Delegate_Hook_tAdapter_defineInvoke  as public defineAdapterInvoke;
  31.             Base_Component_Delegate_Hook_tAdapter_defineDelegate    as public defineAdapterDelegate;
  32.         }
  33.        
  34.         USE tSignal
  35.         {
  36.             Base_Component_Delegate_Hook_tSignal_defineInvoke   as public defineSignalInvoke;
  37.             Base_Component_Delegate_Hook_tSignal_defineDelegate as public defineSignalDelegate;
  38.         }
  39.        
  40.         ### USE tFilter ... // stub
  41.         ### USE tObserver ... // stub
  42.        
  43.         protected $__runtimeConfig = [];
  44.         protected $__defaultConfig = [];
  45.         protected $__autoConfig = [];
  46.        
  47.         /**
  48.          * @discuss final constructor with protected construct-event
  49.          * @see construct()
  50.          */
  51.         final public function __construct(array $__options = [])
  52.         {
  53.             $defaults =
  54.             [
  55.                 '__init'    => TRUE,
  56.                 '__signal' =>   [
  57.                     __METHOD__ => [
  58.                         'PRE_EVENT' =>  [], // delegate 1, delegate 2, ...
  59.                         'POST_EVENT' => []  // delegate 1, delegate 2, ...
  60.                     ],
  61.                 ],
  62.                 '__observer'    =>
  63.                 [
  64.                     __METHOD__ => []    // delegate 1, delegate 2, ...
  65.                 ],
  66.                 '__filter'  =>
  67.                 [
  68.                     __METHOD__ => []    // delegate 1, delegate 2, ...
  69.                 ],
  70.                 '__adapter' =>
  71.                 [
  72.                     __METHOD__ => NULL  // delegate
  73.                 ]
  74.             ];
  75.            
  76.             // reference from protected to private scope
  77.             $this->__Base_tBase_runtimeConfig   =& $this->__runtimeConfig;
  78.            
  79.             // copy from protected into private scope
  80.             $this->__Base_tBase_autoConfig      = $this->__autoConfig;
  81.             $this->__Base_tBase_defaultConfig   = $this->__defaultConfig;
  82.             $this->__Base_tBase_initConfig      = $__options + $defaults;
  83.            
  84.             if(TRUE === $this->__Base_tBase_initConfig['__init'])
  85.             {
  86.                 // load runtime args
  87.                 $this->Base_tBase_init();
  88.                
  89.                 // register signals
  90.                
  91.                 foreach($this->__Base_tBase_initConfig['__signal'] as $method => $events)
  92.                     foreach($events as $event => $hook)
  93.                         foreach($hook as $slotIdent => $delegate)
  94.                             $this->defineSignalInvoke($method, $event, $slotIdent, $delegate, FALSE);
  95.                        
  96.                 foreach($this->__Base_tBase_initConfig['__observer'] as $methodEvent => $observers)
  97.                     foreach($observers as $delegate); // stub
  98.                         ### $this->defineObserverInvoke($methodEvent, $delegate, FALSE);
  99.                        
  100.                 foreach($this->__Base_tBase_initConfig['__adapter'] as $method => $adapter)
  101.                         $this->defineAdapterInvoke($method, $adapter, FALSE);
  102.                        
  103.                 foreach($this->__Base_tBase_initConfig['__filter'] as $method => $filters)
  104.                     foreach($filters as $filter); // stub
  105.                         ### $this->defineFilterInvoke($method, $filter, FALSE);
  106.                
  107.                 // execute PRE_EVENT
  108.                 $this->Base_Component_Delegate_Hook_tSignal_emit(__Method__, 'PRE_EVENT', [$this->__runtimeConfig]);
  109.                
  110.                 // additional
  111.                 $this->construct();
  112.                
  113.                 // filter result
  114.                 ### $filtered = $this->Base_Component_Delegate_Hook_tFilter_emit(__Method__, [$this->__runtimeConfig]);
  115.                 $filtered = $this->__runtimeConfig; // stub
  116.                
  117.                 // observer notify with filtered result
  118.                 ### $this->Base_Component_Delegate_Hook_tObserver_emit(__Method__, $filtered);
  119.                
  120.                 // execute POST_EVENT
  121.                 $this->Base_Component_Delegate_Hook_tSignal_emit(__Method__, 'POST_EVENT', [$filtered]);
  122.             }
  123.         }
  124.        
  125.         /**
  126.          * construct-event instead of __construct()-overwrites
  127.          */
  128.         protected function construct()
  129.         {
  130.         }
  131.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement