Пример #1
0
 public static function makeLazy($className, $args, $after = null, $singleton = false)
 {
     $callback = Gongo_Fn::papply('Gongo_Locator::make', $className, $args);
     if (!is_null($after)) {
         $callback = Gongo_Fn::after($callback, $after);
     }
     if ($singleton) {
         $callback = Gongo_Fn::once($callback);
     }
     return self::get('Gongo_Proxy_Lazy', $callback);
 }
Пример #2
0
 public function __call($method, $args)
 {
     if (strpos($method, '_before') === 0 && strlen($method) > 7) {
         $method = strtolower(substr($method, 7, 1)) . substr($method, 8);
         list($before) = $args;
         $callback = isset($this->_____callbacks[$method]) ? $this->_____callbacks[$method] : array($this->_____, $method);
         return $this->_____callbacks[$method] = Gongo_Fn::before($callback, $before);
     } else {
         if (strpos($method, '_after') === 0 && strlen($method) > 6) {
             $method = strtolower(substr($method, 6, 1)) . substr($method, 7);
             list($after) = $args;
             $callback = isset($this->_____callbacks[$method]) ? $this->_____callbacks[$method] : array($this->_____, $method);
             return $this->_____callbacks[$method] = Gongo_Fn::after($callback, $after);
         } else {
             if (strpos($method, '_around') === 0 && strlen($method) > 7) {
                 $method = strtolower(substr($method, 7, 1)) . substr($method, 8);
                 list($around) = $args;
                 $callback = isset($this->_____callbacks[$method]) ? $this->_____callbacks[$method] : array($this->_____, $method);
                 return $this->_____callbacks[$method] = Gongo_Fn::around($callback, $around);
             } else {
                 if (strpos($method, '_getter') === 0 && strlen($method) > 7) {
                     $property = strtolower(substr($method, 7, 1)) . substr($method, 8);
                     list($around) = $args;
                     if (isset($this->_____getterCallbacks[$property])) {
                         $callback = $this->_____getterCallbacks[$property];
                     } else {
                         $callback = Gongo_Fn::property($this->_____)->getter($property);
                     }
                     return $this->_____getterCallbacks[$property] = Gongo_Fn::around($callback, $around);
                 } else {
                     if (strpos($method, '_setter') === 0 && strlen($method) > 7) {
                         $property = strtolower(substr($method, 7, 1)) . substr($method, 8);
                         list($around) = $args;
                         if (isset($this->_____setterCallbacks[$property])) {
                             $callback = $this->_____setterCallbacks[$property];
                         } else {
                             $callback = Gongo_Fn::property($this->_____)->setter($property);
                         }
                         return $this->_____setterCallbacks[$property] = Gongo_Fn::around($callback, $around);
                     }
                 }
             }
         }
     }
     if (isset($this->_____callbacks[$method])) {
         return call_user_func_array($this->_____callbacks[$method], $args);
     }
     return parent::__call($method, $args);
 }
Пример #3
0
 function after($callback, $after)
 {
     return Gongo_Fn::after($callback, $after);
 }
Пример #4
0
 public function afterInit($sName, $callback)
 {
     if (isset($this->components[$sName])) {
         $this->components[$sName] = Gongo_Fn::after($this->components[$sName], $callback);
     }
 }