um den output type einer agavi action auch nach dem routing zu ändern, kann man innerhalb der action den output type überschreiben.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | /** * assume that 'html' is the standard GET output for this action * when this action is called via POST you want to change the output type to 'json' * because on error or success you want to show small messages per json instead full html */ public function executeRead(AgaviRequestDataHolder $rd ) { return 'Input' ; } public function executeWrite(AgaviRequestDataHolder $rd ) { $this ->getContainer()->setOutputType( $this ->getContext()->getController()->getOutputType( 'json' )); try { // do POST stuff } catch (Exception $e ) { $this ->setAttribute( 'message' , $e ->getMessage()); return 'Error' ; } return 'Success' ; } |