[TYPO3-mvc] Model object tree building with Tx_Extbase_Persistence_ObjectStorage property

Claus Fassing claus at fassing.eu
Wed Sep 29 17:01:21 CEST 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Franz, thank you for your time !

Am 27.09.2010 23:32, schrieb Franz Koch:
> Hey Claus,
> The line above should actually be:
> $dummyPerson =
> $this->objectManager->getObject('Tx_YourExt_Domain_Model_Person');
> 
> I thought that might have been clear - sorry for that. But using
> t3lib_div::makeInstance is also fine for now, because the objectManager
> currenty only does the same thing. But to be better compatible to FLOW3
> and probably make use of upcoming features like "mixins" I personally
> tend to use the objectManager instead where available.

Yes, it was clear, but anyway my fault, I don't realized that there is a
factory behind, I just debug into object manager, however nice to know.
I will going to remember this and use it where possible.


> Ihat might indeed become a problem, because the empty/newly created
> contact doesn't have a uid set. I wasn't sure if it's returning NULL or
> 0 - but I think it's NULL - so we might need to make this a bit more
> complex using a condition - so give this a try:
> 
> <f:for each="{entry.company.contact}" as="contact"><f:alias
> map="{contactId:'{f:if(condition:contact.uid, then:contact.uid,
> else:0)}'}">   
>     <f:form.textbox property="company.contact.{contactId}.forename"
> id="forename"/>
>     <f:form.textbox property="company.contact.{contactId}.lastname"
> id="lastname"/>
> </f:alias>
> </f:for>
>

Same as my company.contact.0.forename method. Work, but if any error
occur the values of contact fields wont be recovered :\
I believe I will never get the uid until persist the object, right ?
<f:for each="{entry.company.contact}" as="contact">
In this case, contact is the person object an the uid of the person
object only set by persist it. Do the storage have an uid ? I guess no,
so I need the counter / position where is my dummy person in, correct ?

> Btw. - you only need the iteration stuff if you plan to allow adding
> multiple persons at once. 

Yes I know. I designed the company object with a possibility to have
more than one contact, but at current time just one contact should be
created.

Another approach :
if (!$entry->getCompany()->getContact()->count()) {
  $contact =
$this->objectManager->getObject('Tx_Myext_Domain_Model_Person');
  $entry->getCompany()->addContact($contact);
}
$this->view->assign('contact', $contact);

Work now with {contact} in the view and send it back with form arguments
{conatct : contact}
and catch contact in the action method and write it back to $entry.
Not tested, just a brainstorm, but may this a solution ?

Greetings Claus
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJMo1TAAAoJELsIv+audObfKPcIAKph6BXiLe921YjTFEC1Tf4D
dkelKfxDGGA75Pkf4cI7CH7n6UGt11NPhyhH0eUlhYWxrXtCbUxLEmM4U41GXWVM
SRejXHpjoTnlnDs3t0IX6Ycni1UiN3gcWCxM8org7xyZiCZo39ZrdkFs2wLswqKQ
U4dpYOuhmLH8ayEMDvphDp5F7+iMIBS3gMnolRCh7it+9QxVgzrv1+jtXKNkdAmK
h3/nlN0PzXI6gmP4zZ0Rx44VqgQ5YPfj7MevSo71rMhB8qtjB5Tk1DbKjmAIPQSW
vhXToTFFlrU7vReVbaD8+c12AwV9mErVpBJJ+0dF69bPiChVfLnyTReZLAMntyI=
=vITo
-----END PGP SIGNATURE-----


More information about the TYPO3-project-typo3v4mvc mailing list