[TYPO3-mvc] [Extbase] Get tstamp / crdate right after persist
Patrick Schriner
patrick.schriner at diemedialen.de
Mon Jun 3 17:33:56 CEST 2013
Hi,
I guess you are right - these properties are not set correctly:
http://api.typo3.org/typo3cms/45/html/class_tx___extbase___persistence___backend.html#af0f9e5de728278d6cc3e1e000c8667e7
Only the "uid" is refreshed immediately.
I once had a similar problem and could not find a way to force-refresh
that tstamp or crdate.
The best thing you can do is to redirect to a different action passing the
new object as an argument - as this will trigger a new mapping (from the
database) the tstamp and crdate will be correct.
Sorry,
Patrick
On Mon, 03 Jun 2013 12:16:19 +0200, Claus Fassing <claus at fassing.eu> wrote:
> Extbase Version : 1.3.4
> TYPO3 Version : 4.5.27
>
> Hello,
>
> I try to get the tstamp / crdate from an object right after add to
> repository and persist.
>
> e.g. I would like to get tstamp / crdate from $newData after persist.
> public function createAction(Tx_EXT_Domain_Model_Data $newData) {
> $this->persistenceManager =
> $this->objectManager->get('Tx_Extbase_Persistence_Manager');
>
> // Existing database entry
> $data = $this->dataRepository->findOneByUid(1);
> $foo = $data->getTstamp(); // Or getCrdate() are working
>
> // Persist data immediately
> $this->dataRepository->add($newData);
> $this->persistenceManager->persistAll();
> // At this moment I can see the record in database with tstamp and
> crdate.
> $bar = $newData->getTstamp(); // Or getCrdate() return NULL
> }
>
> tstamp and crdate are defined as properties with getter and setter
> method in the model.
>
>
> TCA definition :
> [...]
> 'tstamp' => Array(
> 'exclude' => 0,
> 'label' => 'Change date',
> 'config' => Array(
> 'type' => 'none',
> 'format' => 'date',
> 'eval' => 'date',
> ),
> 'crdate' => Array(
> 'exclude' => 0,
> 'label' => 'Creation date',
> 'config' => Array(
> 'type' => 'none',
> 'format' => 'date',
> 'eval' => 'date',
> )
> ),
> [...]
>
> It is possible that tstamp and crdate not reachable after add / persist
> at all ?
> Or what kind of methods I am left to reach the tstamp / crdate in this
> situation ?
>
> Regards Claus
--
Patrick Schriner
More information about the TYPO3-project-typo3v4mvc
mailing list