Feature #37436

PropertyMapper should allow settings like allowCreationForSubProperty('products.[n].tierprices.[n]')

Added by Sebastian Wojtowicz about 3 years ago. Updated over 2 years ago.

Status:Resolved Start date:2012-05-23
Priority:Should have Due date:
Assigned To:Christopher Hlubek % Done:

100%

Category:Property
Target version:TYPO3 Flow Base Distribution - 2.0 beta 1
PHP Version:5.3 Complexity:
Has patch:Yes

Description

In some projects you might want to allow objects with an unknown amount of sub objects like a catalog with products with images, tierprices and colorconfigurations. Imagine a products form with x rows and a <Add row> button at the bottom that dynamically creates new empty rows with an increased index so you can add as many products as you want. In my case it's even quite a lot more complex.

So... something like this is needed

(I)
$this->arguments['newCatalog']->getPropertyMappingConfiguration()->allowCreationForSubProperty('products.[n]');
$this->arguments['newCatalog']->getPropertyMappingConfiguration()->allowCreationForSubProperty('products.[n].tierprices');
$this->arguments['newCatalog']->getPropertyMappingConfiguration()->allowCreationForSubProperty('products.[n].tierprices.[n]');
$this->arguments['newCatalog']->getPropertyMappingConfiguration()->allowCreationForSubProperty('products.[n].tierprices.[n].price');

instead of

(II)
for($i = 0 ; $i < $very_big_number ; $i++){
for($j = 0 ; $j < $very_big_number ; $j++){
$this->arguments['newCatalog']->getPropertyMappingConfiguration()->allowCreationForSubProperty("products.$i");
$this->arguments['newCatalog']->getPropertyMappingConfiguration()->allowCreationForSubProperty("products.$i.tierprices");
$this->arguments['newCatalog']->getPropertyMappingConfiguration()->allowCreationForSubProperty("products.$i.tierprices.$j");
$this->arguments['newCatalog']->getPropertyMappingConfiguration()->allowCreationForSubProperty("products.$i.tierprices.$j.price");
}
}

and also this should be possible

(III)
$this->arguments['newCatalog']->getPropertyMappingConfiguration()->getConfigurationFor('products')->allowProperties('[n]');
$this->arguments['newCatalog']->getPropertyMappingConfiguration()->getConfigurationFor('products')->getConfigurationFor('[n]')->allowProperties('tierprices');
$this->arguments['newCatalog']->getPropertyMappingConfiguration()->getConfigurationFor('products')->getConfigurationFor('[n]')->getConfigurationFor('tierprices')->allowProperties('[n]');
$this->arguments['newCatalog']->getPropertyMappingConfiguration()->getConfigurationFor('products')->getConfigurationFor('[n]')->getConfigurationFor('tierprices')->getConfigurationFor('[n]')->allowProperties('price');

of course it would be handy to have the allowProperties auto-created by a special renderTrustedPropertiesField() method.
I could imagine a view helper like this

(IV)
<f:trustedUnknownAmount preRenderAmount="3" iterator="n">
<f:trustedUnknownAmount preRenderAmount="2" iterator="m">
<f:form.textfield property="products.{n}.tierprices.{m}.name" />
</f:trustedUnknownAmount>
</f:trustedUnknownAmount>

or at least have a alternative short syntax for (III)


Related issues

related to TYPO3.Flow - Bug #37292: PropertyMappingConfiguration::mapUnknownProperties is not... Under Review 2012-05-18
related to TYPO3.Flow - Bug #56107: Property mapping configuration only supports one wildcard... New 2014-02-19

Associated revisions

Revision faaee920
Added by Christopher Hlubek almost 3 years ago

[FEATURE] Allow mapping of indexed property names with placeholder

For multi-valued property types (Doctrine\Common\Collections\Collection or
array) the property mapper uses indexes as property names. To match the
property mapping configuration for any index, the path syntax supports an
asterisk as a placeholder:

$propertyMappingConfiguration
->forProperty('items.*')
->setTypeConverterOption(
'TYPO3\FLOW3\Property\TypeConverter\PersistentObjectConverter',
\TYPO3\FLOW3\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED,
TRUE
);

This also works recursively, as in 'items.*.author'.

Change-Id: I2fa8802ed07d341d5e5bd79bfa5df05244679fe4
Resolves: #37436
Releases: 1.1, 1.2

Revision 444cad6c
Added by Christopher Hlubek almost 3 years ago

[FEATURE] Allow mapping of indexed property names with placeholder

For multi-valued property types (Doctrine\Common\Collections\Collection or
array) the property mapper uses indexes as property names. To match the
property mapping configuration for any index, the path syntax supports an
asterisk as a placeholder:

$propertyMappingConfiguration
->forProperty('items.*')
->setTypeConverterOption(
'TYPO3\FLOW3\Property\TypeConverter\PersistentObjectConverter',
\TYPO3\FLOW3\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED,
TRUE
);

This also works recursively, as in 'items.*.author'.

Change-Id: I2fa8802ed07d341d5e5bd79bfa5df05244679fe4
Resolves: #37436
Releases: 1.1, 1.2

History

#1 Updated by Gerrit Code Review about 3 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/11547

#2 Updated by Gerrit Code Review about 3 years ago

Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/11591

#3 Updated by Karsten Dambekalns about 3 years ago

  • Target version changed from 1.1 to 1.1 RC1

#4 Updated by Gerrit Code Review about 3 years ago

Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/11594

#5 Updated by Gerrit Code Review about 3 years ago

Patch set 2 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/11547

#6 Updated by Gerrit Code Review about 3 years ago

Patch set 3 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/11547

#7 Updated by Gerrit Code Review about 3 years ago

Patch set 4 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/11547

#8 Updated by Gerrit Code Review about 3 years ago

Patch set 5 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/11547

#9 Updated by Gerrit Code Review about 3 years ago

Patch set 6 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/11547

#10 Updated by Gerrit Code Review about 3 years ago

Patch set 7 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/11547

#11 Updated by Gerrit Code Review about 3 years ago

Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/12166

#12 Updated by Gerrit Code Review about 3 years ago

Patch set 2 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/12166

#13 Updated by Gerrit Code Review about 3 years ago

Patch set 3 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/12166

#14 Updated by Karsten Dambekalns about 3 years ago

  • Assigned To set to Christopher Hlubek

#15 Updated by Karsten Dambekalns about 3 years ago

  • Target version changed from 1.1 RC1 to 2.0 beta 1

#16 Updated by Gerrit Code Review almost 3 years ago

Patch set 4 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/12166

#17 Updated by Gerrit Code Review almost 3 years ago

Patch set 1 for branch FLOW3-1.1 has been pushed to the review server.
It is available at http://review.typo3.org/14575

#18 Updated by Karsten Dambekalns over 2 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF