[TYPO3-50-general] Accessing the AspectContainer / AOPBrowser
Michael Feinbier
typo3 at feinbier.net
Fri Mar 14 19:55:08 CET 2008
Hi robert,
i think i need help :(
my wish was to define a method "getAdvicesForMethod" beneath the
"getAspectContainers" in the AOP-Framework. But it shows strange
behaviour. Please have a quick look on this implementation (maybe u have
to c&p to an ide) :
public function getAdvicesForMethod(T3_FLOW3_Reflection_Class $class,
ReflectionMethod $method) {
$matchingAdvices = array();
foreach ($this->aspectContainers as $aspectContainer) {
$pointcuts = $aspectContainer->getPointcuts();
foreach ($pointcuts as $pointcut) {
# just for debugging vs. $this->findPointcut
if(isset($this->aspectContainers[$pointcut->getAspectClassName()]))
echo 'Aspect exist';
if($pointcut->matches($class, $method, uniqid()))
#set to pointcutexpression for testing
$matchingAdvices[] = $pointcut->getPointcutExpression();
}
}
return $matchingAdvices;
}
Now, if i call it like this:
$fw = $this->componentManager->getComponent('T3_FLOW3_AOP_Framework');
$refClass = new T3_FLOW3_Reflection_Class('T3_TestPackage_BasicClass');
$refMethod = $refClass->getMethod('getSomeProperty');
print_r( $fw->getAdvicesForMethod($refClass,$refMethod) );
FLOW3 throws this exception:
No aspect class "T3_TestPackage_PointcutTestingAspect" found while
searching for pointcut "pointcutTestingTargetClasses". Which is quite
strange, because the pointcutTestingTargetClasses is within the
PointcutTestingAspect. The ex. is thrown in
T3_FLOW3_AOP_Framework->findPointcut
where the first line is
if (!isset($this->aspectContainers[$aspectClassName])) throw new
RuntimeException('No aspect cla...
when debugging the aspectContainers via print_r you can see that the
array is empty.
That doesnt make sense to me, because in my method (which is in THIS
class) the aspectContainers array gets traversed and contains methods!
Any hints?
thanks and have a nice weekend
Robert Lemke schrieb:
> Hi Michael,
>
> Am 13.03.2008 um 11:50 schrieb Michael Feinbier:
>
>>> Why don't you analyse the classes? It's pretty easy to search for the
>>> class and read out the doccomment... You can check out the FLOW3CGL and
>>> PHPCodeSniffer Packages...
>>> Perhaps it's easier to collect the classes and aspects directly from the
>>> Classes-folder and interprete them afterwards.
>>>
>>
>> Yes, of course that would work. But I thought I didn`t have to reinvent
>> the wheel. All this collection, parsing, proxiing is already done by the
>> AOP-Framework, so why not using that?
>> Furthermore i want to present the registrered advices and pointcuts
>> exactly as the aop-framework will use. Maybe my recoding of the advice
>> collecting is in somethings different from that of the aop-framework. So
>> the Browser would show different results.
>
> I suggest that we rather add some features to the AOP Framework class
> instead that you write your own parsing routines.
>
> What functions do you need? A "getAspectContainers()" would be very easy
> to add but even if you need an array of classes and what advices were
> applied to them, that could be easily done.
>
> If you can do that yourself, just try it and open a ticket describing a
> feature and attach a patch to it.
>
> If you want me to do it, just open a ticket (or more) describing exactly
> what you need.
>
> Best,
> robert
--
kind regards from Bielefeld
Michael
Error 404: The city you are looking for doesn't exist.
http://www.denkweite.de | http://www.feinbier.net
More information about the TYPO3-project-5_0-general
mailing list