Created
September 18, 2012 08:48
-
-
Save Allisone/3742100 to your computer and use it in GitHub Desktop.
Example that fails using Change I2fa8802e
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function getConfigurationFor($propertyName) { | |
if (isset($this->subConfigurationForProperty[$propertyName])) { | |
return $this->subConfigurationForProperty[$propertyName]; | |
} elseif (isset($this->subConfigurationForProperty[self::PROPERTY_PATH_PLACEHOLDER])) { | |
return $this->subConfigurationForProperty[self::PROPERTY_PATH_PLACEHOLDER]; | |
} | |
return new \TYPO3\FLOW3\Property\PropertyMappingConfiguration(); | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$pMC->allowCreationForSubProperty('items.*'); | |
$pMC->forProperty('items.*')->setTypeConverterOption( | |
'TYPO3\FLOW3\Property\TypeConverter\PersistentObjectConverter', | |
\TYPO3\FLOW3\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_OVERRIDE_TARGET_TYPE_ALLOWED, TRUE); | |
And in a template have | |
<f:form.textfield property="items.0.__type" value="\My\Package\Domain\Model\SomeClass"/> | |
(imagine this to be only the first row, and the rest being autogenerated using javascript when the use hits a "add more" button ...) | |
Not the best example maybe, but it's short and obvious and in fact I have such a case where items is a collection of objects that can vary in type | |
and so in the template I have to set the concrete type like seen above | |
@var \Doctrine\Common\Collections\Collection<\My\Package\Domain\Model\AbstractClass> | |
Short explanation for the problem: | |
================================== | |
On pulling the configuration for items.0.__type, first the configuration for "items" will be pulled, then its subconfiguration for "0" | |
(which has been automatically generated by the renderTrustedFields & co functionality), then its subconfiguration for "__type" | |
Here comes the problem, the automatic generated configuration gets in our way. We want our rules to be used, | |
the one that we declared in our controller maybe, but because "0" is more specific than "*", | |
the "0" path-configuration will be used instead !!! and all its subconfigurations, and none of the "*.xyz" configurations. | |
Now one could just add a specific exceptional rule in the controller to handle this one specific problem above. | |
But this becomes impossible if you have a path as complex as this... chapters.*.parts.*.cards.*.sides.*.answers.*.stringVersions.* | |
and not only 0 but always 0,1 and 2 as fixed rows in your templates. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment