[FLOW3-general] AOP question
Fernando Arconada
falcifer2001 at yahoo.es
Sat May 28 13:55:44 CEST 2011
Hello
I want to map an argument passed as Json to an Entity for a controller
action. I've tried with AOP. But I dont know how to modify the argument
or reinject the new request. ¿ideas?
----------- Action -----------------
public function saveAction(\F3\Sifpe\Domain\Model\Empresa $empresa) {
//do something
}
----------- Aspect --------------
/**
*
* @before method(F3\Sifpe\Controller\EmpresaController->saveAction())
* @param \F3\FLOW3\AOP\JoinPointInterface $joinPoint The current
join point
* @return void
*/
public function mapEmpresaJsonToEntity(\F3\FLOW3\AOP
\JoinPointInterface $joinPoint){
$empresaJson = $joinPoint->getMethodArgument('empresa');
// do something with the json
$empresaEntity = new \F3\Sifpe\Domain\Model\Empresa();
$myController = $joinPoint->getProxy();
$request = $myController->getControllerContext()->getRequest()-
>setArgument('empresa',$empresaEntity);
var_dump($joinPoint->getMethodName());
}
------------------ comments -----------------------
* Use Json as parameter in my action is not conceptually clear: my action
has to persist an Entity not to manage Json
* use a JoinPoint in a point before saveAction like initializeAction or
similar isnt also clear cause then I need to switch-case (very ugly)
* ¿a requestHandler? dont know, I could solve this problem, but It will
be better a gerneral solution to change arguments of a method before
execution
More information about the FLOW3-general
mailing list