[TYPO3-mvc] createAction: get uid of the new object

Tim Schoch | GSTALTIG tim.schoch at gstaltig.ch
Fri Sep 30 12:03:42 CEST 2011


Hi Christian

this can be done by persisting the objects prior to the redirect.
simply inject the persistanceManager in your controller and call persistAll. After that $newLehrgang->getUid() will return what you're looking for.

Code:

    /**
    * @param Tx_Extbase_Persistence_Manager $persistanceManager
    * @return void
    */
    public function injectPersistanceManager(Tx_Extbase_Persistence_Manager $persistanceManager) {
      $this->persistanceManager = $persistanceManager;
    }
    /**
    * @var Tx_Extbase_Persistence_Manager
    */
    protected $persistanceManager;

And inside the new Action:
$this->persistanceManager->persistAll();

Tim


More information about the TYPO3-project-typo3v4mvc mailing list