[TYPO3-mvc] Where to put automatic value calculation

Steffen Ritter info at rs-websystems.de
Tue Dec 8 12:29:04 CET 2009


Jochen Rau schrieb:
> Hi Steffen.
> 
> schrieb Steffen Ritter:
>> Steffen Ritter schrieb:
>>> Hey list,
>>> I wanna set some field of an object automatically/autogenerated when
>>> creating an new object, things like a serial or an password, sth. like
>>> this... how do i do best?
> 
>> OK,
>> the storage backend knows about the "new object" status and implements
>> the isNew() functionality.
> 
> Did you mean the persistence backend? The storage backend is not aware 
> of the object status. It should only translate the query into something 
> useful for the database/SOAP client/xml file ....
> 
yes i did, sry

>> I added an Method _onFirstPersist to the ObjectsInterface which is
>> called by the StorageBackend in persistObject if isNew($object) returns
>> true.
>>
>> Patch may be found issue tracker soon.
> 
> Thanks for the patch. We definitely have to provide a clean way to 
> control the overall life cycle of an object (and its properties). But 
> that is the big scope ;-). Let's focus on your problem.
> 
> Your proposed solution introduces a template method _onFirstPersist() 
> which has to be implemented inside a Domain Object. This will mix up 
> domain logic with the way the domain object is persisted.
> 
> I would prefer to overwrite the add() method of the Peristence 
> Repository and call a 
> Tx_MyExt_Domain_Service_InvoiceNumberProvider::getInvoiceNumber().
> 
> Regards
> Jochen
> 
I did this already... but add/update in repository are not called 
everytime...
persisting an object which is  modified by php code will be persistet 
without getting to the update method... So this is not the overall 
conclusion.

As you said, it's missing a "liveCycle" solution,
wie probably could mix up both ideas... Create Interface "LiceCycleService"
and if a Class {DomainObject}Service exists and implements the 
interface, the persistance backend should automatically trigger those 
methods.

what do you think?



More information about the TYPO3-project-typo3v4mvc mailing list