Go\Core\AspectContainer::registerAdvisor PHP Method

registerAdvisor() public method

Store the advisor in the container
public registerAdvisor ( Go\Aop\Advisor $advisor, string $id )
$advisor Go\Aop\Advisor Instance
$id string Key for advisor
    public function registerAdvisor(Aop\Advisor $advisor, $id);

Usage Example

Example #1
0
 /**
  * Check that list of advices for fields works correctly
  */
 public function testGetSinglePropertyAdviceForClassFromAdvisor()
 {
     $propName = 'container';
     // $this->container;
     $pointcut = $this->getMock('Go\\Aop\\Pointcut');
     $pointcut->expects($this->any())->method('getClassFilter')->will($this->returnValue(TruePointFilter::getInstance()));
     $pointcut->expects($this->any())->method('matches')->will($this->returnCallback(function ($point) use($propName) {
         return $point->name === $propName;
     }));
     $pointcut->expects($this->any())->method('getKind')->will($this->returnValue(Pointcut::KIND_PROPERTY));
     $advice = $this->getMock('Go\\Aop\\Advice');
     $advisor = new DefaultPointcutAdvisor($pointcut, $advice);
     $this->container->registerAdvisor($advisor, 'test');
     $advices = $this->adviceMatcher->getAdvicesForClass(__CLASS__);
     $this->assertArrayHasKey(AspectContainer::PROPERTY_PREFIX, $advices);
     $this->assertArrayHasKey($propName, $advices[AspectContainer::PROPERTY_PREFIX]);
     $this->assertCount(1, $advices[AspectContainer::PROPERTY_PREFIX]);
 }
All Usage Examples Of Go\Core\AspectContainer::registerAdvisor