[TYPO3-mvc] Executing code after data has been persisted?

Pankaj Lele pankaj at lelesys.com
Wed Jun 1 16:04:24 CEST 2011


> you can inject the persistenceManager to you controller and invoke persistAll() when you need to persist all data.
>
> /**
>   * DI extbase persistence manager
>   *
>   * @param Tx_Extbase_Persistence_Manager $persistenceManager
>   */
> public function injectPersistenceManager(Tx_Extbase_Persistence_Manager $persistenceManager) {
> 	$this->persistenceManager = $persistenceManager;
> }
>
> public function myAction() {
> 	$this->persistenceManager->persistAll();
> ...
> 	Tx_My_Services_Mail::send($whatEver);
> }

Another way is, In your controller->someAction method:

$yourRepo->add($yourObject); // assumed yourRepo is injected properly
$this->objectManager->get('Tx_Extbase_Persistence_Manager')->persistAll(); 
// for every controller the objectManager is already injected.
$yourObject->getUid(); // this returns the UID of new record so you can 
use it to insert in the links.

-- 

With best regards,
Pankaj Lele
---------------------------

CTO & Executive Director
Lelesys Infotech Pvt. Ltd.
Pune/Goa, India

Web: http://www.lelesys.com

[Certified TYPO3 Integrator]


More information about the TYPO3-project-typo3v4mvc mailing list