Php 拦截器不';在JMSAopBundle(Symfony2 AOP)上工作

Php 拦截器不';在JMSAopBundle(Symfony2 AOP)上工作,php,symfony,aop,Php,Symfony,Aop,我正试图在Symfony2上创建一个方面,但我按照中的说明进行操作,找不到问题所在。这是我的服务。yml: exception_pointcut: class: AGF\Services\Aspects\Exceptions\ExceptionPointcut tags: - { name: jms_aop.pointcut, interceptor: exception_interceptor } exception_interc

我正试图在Symfony2上创建一个方面,但我按照中的说明进行操作,找不到问题所在。这是我的服务。yml:

exception_pointcut:
        class:    AGF\Services\Aspects\Exceptions\ExceptionPointcut
        tags:
          - { name: jms_aop.pointcut, interceptor: exception_interceptor }  

exception_interceptor:
        class:    AGF\Services\Aspects\Exceptions\ExceptionInterceptor
        arguments: [@security.context, @logger] 
这是我的“切入点”:


您可以尝试首先添加一个
返回true当我在异常切入点::匹配方法中输入“return true”时,在
异常切入点::匹配方法的末尾出现以下错误:致命错误:调用成员函数loadInterceptors()在第37I行的/usr/local/zend/apache2/htdocs/ebusagf/app/cache/dev/jms_aop/proxies/Symfony-Bridge-Monolog-Logger.php中的非对象上,我也有同样的问题,您是否纠正了它?解释了始终从
matchesMethod
返回
true
时的致命错误。问题是,当代理对象还没有拦截加载程序时,您试图拦截每个方法,甚至是构造函数
<?php
namespace AGF\Services\Aspects\Exceptions;

use JMS\AopBundle\Aop\PointcutInterface;

class ExceptionPointcut implements PointcutInterface
    {

    public function matchesClass(\ReflectionClass $class) 
        {
        return true;
        }

    public function matchesMethod(\ReflectionMethod $method)
        {

            if($method->name == '__construct')
                {
                return false;   
                }

        }

    }
<?php
namespace AGF\Services\Aspects\Exceptions;

use CG\Proxy\MethodInterceptorInterface;
use CG\Proxy\MethodInvocation;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\Security\Core\SecurityContextInterface;

class ExceptionInterceptor implements MethodInterceptorInterface
    {

    private $context;
    private $logger;

    public function __construct(SecurityContextInterface $context, LoggerInterface $logger)
        {

        $this->context = $context;
        $this->logger = $logger;    
        $this->logger->debug('HOLA2');

        }

    public function intercept(MethodInvocation $invocation) 
        {

        try {
            return $invocation->proceed();
            }   
        catch (\Exception $e)
            {
            $this->logger->err($e);
            }   

        }

    }