[TYPO3-mvc] Calling persistAll()
Xavier Perseguers
typo3 at perseguers.ch
Sat Jul 25 10:20:21 CEST 2009
Hi Sebastian,
Sebastian Kurfürst wrote:
> Hi,
>> What should I do to call persistAll() from an Extbase Controller?
> fetch the Persistence_manager (it is singleton) and call PersisteAll on
> it :-)
> Greets,
> Sebastian
That's really really funny. I did that yesterday but it did not work
(perhaps I did not see the persistAll method and tried to access the
backend and then the persist method). Anyway. It now works.
Simple code for all of us (used in plugin Movie from
EXT:mvc_extjs_samples to save a movie coming from an ExtJS form and
submitted with an AJAX call):
/**
* Updates an existing movie.
*
* @param Tx_MvcExtjsSamples_Domain_Model_Movie $movie The existing,
unmodified movie
* @param Tx_MvcExtjsSamples_Domain_Model_Movie $updatedMovie A clone
of the original movie with the updated values already applied
* @return void
* @ajax
*/
public function updateAction(Tx_MvcExtjsSamples_Domain_Model_Movie
$movie, Tx_MvcExtjsSamples_Domain_Model_Movie $updatedMovie) {
try {
$movieRepository =
t3lib_div::makeInstance('Tx_MvcExtjsSamples_Domain_Model_MovieRepository');
$movieRepository->replace($movie, $updatedMovie);
$persistenceManager =
t3lib_div::makeInstance('Tx_Extbase_Persistence_Manager');
/* @var $persistenceManager Tx_Extbase_Persistence_Manager */
$persistenceManager->persistAll();
echo '{success:true}';
} catch (Exception $e) {
echo '{success:false}';
}
// Do not do further processing
exit;
}
It still is not perfect missing an AJAX dispatcher but at least it now
works ;-)
--
Xavier Perseguers
http://xavier.perseguers.ch/en
One contribution a day keeps the fork away
More information about the TYPO3-project-typo3v4mvc
mailing list