[TYPO3-mvc] property persistence on showAction

Gianluca Strafella gianluca.strafella at webformat.com
Fri Dec 20 09:10:06 CET 2013


Ludwig ++
Il 14/12/2013 21:58, Ludwig Rafelsberger ha scritto:
> Am Sat, 14 Dec 2013 18:26:21 +0100
> schrieb Henry DoShell <digital at dollerschell.de>:
>
>> But it does not work. What I am missing? Can someone push me in the
>> right direction?
>
> Something must be changed in $main for a persist action to make sense. I
> assume the change to $main has happened e.g. in the frontend by a
> form, which is then submitted to this action. Alright so far.
>
> But what misses to me most clearly in this snippet, is the repository or
> more precisely lack of usage of any repository method.
>
> If the object $main is already in the Persistence (database…), you need
> something like a
>
> /**
>   * Repository for Mains
>   *
>   * \DoShell\TouristBbhotel\Domain\Repository\MainRepository
>   * @inject
>   */
> protected $mainRepository;
>
>
> /**
>   * action show
>   *
>   * @param \DoShell\TouristBbhotel\Domain\Model\Main $main
>   * @return void
>   */
> public function showAction(\DoShell\TouristBbhotel\Domain\Model\Main
> $main) {
> 	// did some changes to $main in the frontend?
> 	$this->view->assign('main', $main);
> 	$this->mainRepository->update($main);
> }
>
>
> Changed objects (that are updated/inserted/… in the Repository) are
> automatically persisted after the action, so no need for the explicit
> ->persistAll() call here.
>
> Cheers,
>
> Ludwig
> ---
> PS: Are you sure you want to *change* something in an action called
> "show" and to call your objects "main"? Not that I know your domain,
> but from the outside this looks confusing to mee.
>


Gianluca Strafella

Software Developer
gianluca.strafella at webformat.com
Tel.   +39-0427-926.389

WEBFORMAT srl – www.webformat.com
Via Mecenate, 76 - 20138 MILANO
Corte Europa, 12 - 33097 SPILIMBERGO (PN)


More information about the TYPO3-project-typo3v4mvc mailing list