[Flow] Flow 2.2, creating many objects at once, any news?
mario chiari
ml at mariochiari.net
Thu Sep 4 21:52:34 CEST 2014
Hi
Say I have a Flow 2.0 application with 1:M models Father/Son, and views
to create or edit a number of Fathers and their Sons at once (some JS
let a user to add new fields on the fly to the html forms).
I would like to know if Flow 2.2 let me to simplify my code.
Father : name:string, picture:resource, sons:Collection/son
Son : father:Father, name:string.
Setters and getters are as by default but:
public function setSons(\Doctrine\Common\Collections\Collection $sons) {
foreach ($sons as $son){$son->setFather($this);}
$this->sons = $sons;
To define a Father createController() which works, it seemed to me that
I need to initialize it as follow:
/**
* Initialize the create action
*
* @return void
*/
public function initializeCreateAction() {
$this->arguments['newFathers']
->getPropertyMappingConfiguration()
->forProperty('*')->allowAllProperties()->setTypeConverterOption(
'TYPO3\Flow\Property\TypeConverter\PersistentObjectConverter',
\TYPO3\Flow\Property\TypeConverter
\PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED, TRUE);
for($i = 0 ; $i < 9 ; $i++){ // use 99 or 999 if you need
$this->arguments['newFathers']
->getPropertyMappingConfiguration()
->forProperty($i.'.sons.*')
->allowAllProperties()->setTypeConverterOption(
'TYPO3\Flow\Property\TypeConverter\PersistentObjectConverter',
\TYPO3\Flow\Property\TypeConverter
\PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED, TRUE );
}
$this->arguments['newFathers']
->getPropertyMappingConfiguration()
->setTypeConverterOption('TYPO3\Flow\Property\TypeConverter
\PersistentObjectConverter',\TYPO3\Flow\Property\TypeConverter
\PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED,TRUE);
}}
Question is: in Flow 2.2, may I avoid to initializeCreate, or at least
the foreach up to 9, i.e., may I write something like:
forProperty('*.sons.*')?
In my real project, I have suboject of subobject of ..., for several
levels, and I would like to get rid of all the initialize actions.
Thanks
Cheers
mario
More information about the Flow
mailing list