Go\Proxy\ClassProxy::injectJoinPoints PHP Method

injectJoinPoints() public static method

NB This method will be used as a callback during source code evaluation to inject joinpoints
public static injectJoinPoints ( string $className, array $advices = [] ) : void
$className string Aop child proxy class
$advices array List of advices to inject into class
return void
    public static function injectJoinPoints($className, array $advices = [])
    {
        $reflectionClass = new ReflectionClass($className);
        $joinPoints = static::wrapWithJoinPoints($advices, $reflectionClass->getParentClass()->name);
        $prop = $reflectionClass->getProperty('__joinPoints');
        $prop->setAccessible(true);
        $prop->setValue($joinPoints);
        $staticInit = AspectContainer::STATIC_INIT_PREFIX . ':root';
        if (isset($joinPoints[$staticInit])) {
            $joinPoints[$staticInit]->__invoke();
        }
    }

Usage Example

Esempio n. 1
0
     * Property was created automatically, do not change it manually
     */
    private static $__joinPoints = array();
    public function publicMethod()
    {
        return self::$__joinPoints['method:publicMethod']->__invoke($this);
    }
    protected function protectedMethod()
    {
        return self::$__joinPoints['method:protectedMethod']->__invoke($this);
    }
    public static function publicStaticMethod()
    {
        return self::$__joinPoints['static:publicStaticMethod']->__invoke(\get_called_class());
    }
    protected static function protectedStaticMethod()
    {
        return self::$__joinPoints['static:protectedStaticMethod']->__invoke(\get_called_class());
    }
    public function publicMethodDynamicArguments($a, &$b)
    {
        $argsList = \func_get_args();
        return self::$__joinPoints['method:publicMethodDynamicArguments']->__invoke($this, array($a, &$b) + $argsList);
    }
    public function publicMethodFixedArguments($a, $b, $c = null)
    {
        return self::$__joinPoints['method:publicMethodFixedArguments']->__invoke($this, array($a, $b, $c));
    }
}
\Go\Proxy\ClassProxy::injectJoinPoints('Test\\ns1\\TestClass', array('method' => array('publicMethod' => array(0 => 'advisor.Test\\ns1\\TestClass->publicMethod'), 'protectedMethod' => array(0 => 'advisor.Test\\ns1\\TestClass->protectedMethod'), 'publicStaticMethod' => array(0 => 'advisor.Test\\ns1\\TestClass->publicStaticMethod'), 'protectedStaticMethod' => array(0 => 'advisor.Test\\ns1\\TestClass->protectedStaticMethod'), 'publicMethodDynamicArguments' => array(0 => 'advisor.Test\\ns1\\TestClass->publicMethodDynamicArguments'), 'publicMethodFixedArguments' => array(0 => 'advisor.Test\\ns1\\TestClass->publicMethodFixedArguments'))));
All Usage Examples Of Go\Proxy\ClassProxy::injectJoinPoints