public function testRegistration() { $registry = Registry::getRegistry(); $registry->parseClass('GuiseTest\\DummyAspect'); $pointcuts = $registry->getPointcuts(); $joinpoints = $registry->getJoinpoints('matchAll'); $this->assertEquals(array('* * (..)' => array('matchAll')), $pointcuts); $this->assertEquals(array('around' => array('GuiseTest\\DummyAspect/aroundEverything')), $joinpoints); }
public function testHandler() { $registry = Registry::getRegistry(); $weaver = new Weaver(); $registry->parseClass('GuiseTest\\DummyAspect'); $weaver->weave('GuiseTest\\WeaverTarget'); $this->assertTrue(method_exists('GuiseTest\\WeaverTarget', 'callmePublic')); $this->assertTrue(method_exists('GuiseTest\\WeaverTarget', '__guise_method__callmePublic')); }
/** * Weave "broad" matching ("* * (..)") advices to method * * @param \ReflectionMethod $method */ protected function weaveBroad(\ReflectionMethod $method) { $registry = Registry::getRegistry(); $pointcuts = $registry->getPointcuts(); if (empty($pointcuts['* * (..)'])) { return; } foreach ($pointcuts['* * (..)'] as $alias) { $joinpoints = $registry->getJoinpoints($alias); foreach ($joinpoints as $type => $advices) { switch ($type) { case 'before': $this->weaveAdvicesBefore($method, $advices); break; case 'around': $this->weaveAdvicesAround($method, $advices); break; case 'after': $this->weaveAdvicesAfter($method, $advices); break; } } } }