Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * allows you to replaace the core-function of a method without editing your class-file
- *
- * <code>
- * function myMethod()
- * {
- * // do additional stuff
- * $this->prototype('myMethod');
- * // do additional stuff
- * // return $whatever;
- * }
- * </code>
- *
- * 1. adapter-lookup
- *
- * 2.1 send signal PRE_EVENT with unfiltered parameters
- * 2.2 filter parameters
- * 2.3 run method-filters
- * 2.3.1 run outer-filters
- * 2.3.2 execute virtual method
- * 2.3.3 execute virtual proto or physical existing proto
- * 2.4 filter result
- * 2.5 observer notify with filtered result
- * 2.6 send signal POST_EVENT with filtered result
- * 2.7 return filtered result
- */
- protected function prototype($__function, $__parameters)
- {
- if(isset($__parameters['this']))
- unset($__parameters['this']);
- $class = get_called_class();
- $function = $__function;
- if(TRUE === $this->Core_Object_tAdapter_exists($class, $function))
- return $this->Core_Object_tAdapter_emit($class, $function, $__parameters);
- $this->Core_Object_tSignal_emit($class, $function, 'PRE_EVENT', $__parameters);
- $data = $this->Core_Object_tFilter_emit($class, $function, $__parameters, ['event' => 'DATA']);
- $result = $this->Core_Object_tMethodFilter_emit($class, $function, $data, function(array $__params) use ($function, $data)
- {
- $result = NULL;
- if(TRUE === $this->Core_Object_tMethod_exists($function))
- {
- $result = $__params = $this->Core_Object_tMethod_emit($function, $__params);
- }
- if(TRUE === $this->Core_Object_tMethodProto_exists($function))
- {
- $result = $this->Core_Object_tMethodProto_emit($function, $__params);
- }
- else
- {
- $proto = $function === '__construct'
- ? $this->__initConfig['__main']
- : $this->__initConfig['__protoprefix'].$function;
- if($proto === $function)
- {
- throw new \Exception('Proto is called method '.$function);
- return $__params;
- }
- if(method_exists($this, $proto))
- $result = $this->Core_Object_tInvoke_method($proto, $__params);
- }
- return $result;
- });
- $result = [$result];
- $result = $this->Core_Object_tFilter_emit($class, $function, $result, ['event' => 'RESULT']);
- $this->Core_Object_tObserver_emit($class, $function, $result);
- $this->Core_Object_tSignal_emit($class, $function, 'POST_EVENT', $result);
- return $result[0];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement