[TYPO3-mvc] own Tx_Extbase_MVC_Exception_InvalidArgumentValue handler

Simon Schaufelberger (Schaufi) simonschaufi at jesus.de
Mon Jul 9 20:08:22 CEST 2012


Hi,
thank you for your response!

this is actually not what i expected as an answer since i have to do 
everything completely different and i don't really want to do extbase 
validation by hand if extbase does that for me.

Regards, Schaufi


Am 07.07.2012 14:04, schrieb Claus Due:
> Hi Simon,
>
> One way is this:
>
> - Add an initializeXyzAction() method
> - Perform validation here using $this->request->getArgument('name');
> - Manually add ValidationErrors to an array and $this->request->setErrors($errorArray)
> - Let the object on your "real" method be an optional argument
> - Remove the argument if the validation problem was an incorrect UID (optional, see next)
>
> This should make sure that you will get a NULL object but all validation errors, and assuming
> you've used the correct argument name (dotted syntax) you can even add the validation
> errors directly to the the object's properties instead of completely rejecting it - which could be
> useful.
>
> InitializeXyzAction comes after request arguments are mapped and also after all properties
> have been built (including flash message container). In addition, the errors will of course
> trigger the usual error behavior in forms etc.
>
> Hope this helps. It's been a long time since I've done this, so please excuse if some parts are
> unclear or incorrect according to your Extbase version…
>
> Cheers,
> Claus
> http://fedext.net
>
> On Jul 7, 2012, at 1:42 PM, Simon Schaufelberger (Schaufi) wrote:
>
>> Hi,
>>
>> i need some help with extbase internals.
>>
>> i found this very helpful snippet to avoid exceptions if the url contains an invalid id of an object like index.php?tx_myext_pi1[foo]=2&<controller, action...>
>>
>> https://gist.github.com/1014442
>>
>> i modified it a bit to add a flash message and redirect to another page. the redirect works but the flash message will not be show.
>>
>> This is the code in my controller:
>>
>> /**
>> * @return void
>> */
>> public function mapRequestArgumentsToControllerArguments() {
>> 	try {
>> 		parent::mapRequestArgumentsToControllerArguments();
>> 	} catch (Tx_Extbase_MVC_Exception_InvalidArgumentValue $exception) {
>> 		$this->flashMessageContainer->add('test');
>> 		$this->redirect('list', 'Advertisement', NULL, NULL, 'pinboard');
>> 	}
>> }
>>
>> when i print_r() of the flashMessageContainer, i get an object back. i don't know much about extbase internals but somehow this flash message will not be added correctly. i guess since this code will be executed quite early, the flashMessageContainer is not setup correctly at this time.
>>
>> what must i do to setup flashMessageContainer so that the flashmessage will be stored in the session and will be printed out on the redirected page?
>> --
>> Regards, Schaufi
>>
>> _______________________________________________
>> TYPO3-project-typo3v4mvc mailing list
>> TYPO3-project-typo3v4mvc at lists.typo3.org
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
>



More information about the TYPO3-project-typo3v4mvc mailing list