[FLOW3-general] Introduce Method WITH parameters via AOP Advice and Interface
Torsten Blindert
register at by-torsten.de
Mon Oct 31 12:24:32 CET 2011
I'm referring to this Part: http://flow3.typo3.org/documentation/guide/partiii/aspectorientedprogramming.html#interface-introduction
It says
/**
* Around advice, implements the new method "newMethod" of the
* "NewInterface" interface
*
* @param \TYPO3\FLOW3\AOP\JoinPointInterface $joinPoint The current join point
* @return void
* @FLOW3\Around("method(Example\MyPackage\OldClass->newMethod())")
*/
public function newMethodImplementation(\TYPO3\FLOW3\AOP\JoinPointInterface $joinPoint) {
// We call the advice chain, in case any other advice is declared for
// this method, but we don't care about the result.
$someResult = $joinPoint->getAdviceChain()->proceed($joinPoint);
$a = $joinPoint->getMethodArgument('a');
$b = $joinPoint->getMethodArgument('b');
return $a + $b;
}
Which suggests, that a new method looking something like this is introduced:
public function newMethod($a, $b);
And this I like to achieve too.
To be more concretely, I want to add an protected variable, a getter and a setter to security context. New variable and getter can be easily achieved with AOP, but the setter needs to have a parameter (obviously)... and thats seems to be impossible. Currently I make use of \TYPO3\FLOW3\Reflection\ObjectAccess->setProperty which is not as elegant as using a "real" setter method.
Torsten
On 31.10.2011, at 11:10, Bastian Waidelich wrote:
> Torsten Blindert wrote:
>
> Hi Torsten,
>
>> if method introductions with parameters aren't currently supported,
>> than the example snipped in the AOP part of the documentation is wrong. [...]
>
>> $joinPoint->getMethodArgument('a')
>
> The example in the documentation is about *advising* methods and accessing their parameters, not about introducing new parameters. But probably we've just got our wires crossed. What do you want to achieve and do you have a snippet of your code?
>
> Bastian
> _______________________________________________
> FLOW3-general mailing list
> FLOW3-general at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general
More information about the FLOW3-general
mailing list