[TYPO3-mvc] property persistence on showAction

Ludwig Rafelsberger ludwig.rafelsberger at gmx.at
Sat Dec 14 21:58:03 CET 2013


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.


More information about the TYPO3-project-typo3v4mvc mailing list