Hallo,
ich kämpfe mit dem Property Mapper bei einem verschachtelten Objekt.
Es gibt das Objekt Types das beinhaltet x Objekte des Types Workspace und dieses wiederum beinhaltet x Objekte des Types Instructions.
Das Ganze wird im Fe angelegt und kann über einen Ajaxaufruf mit Formularfeldern zum Anlegen von Workspaces und Instructions gefüllt werden.
Beim Speichern wird dann ein Array übergeben, das so ankommt:
Array
(
[action] => updateEverything
[controller] => Types
[types] => Array
(
[__identity] => 11
[workspace] => Array
(
[0] => Array
(
[uid] => 1
[name] => WS1
[location] => b1
[instructions] => Array
(
[0] => Array
(
[name] => Anleitung 1
[small] => kurz
[middel] => mittel
[large] => lang
[teaser] => beschreibung
)
)
)
[1] => Array
(
[uid] => 2
[name] => WS2
[location] => B2
)
)
)
)
Es gibt also das Objekt Types mit der UID 11, darin die Workspaces WS1 (UID 1) und WS2 (UID 2). In WS1 liegt die Instruction Anleitung 1, die noch nicht persistiert ist.
Das ganze soll nun gespeichert werden.
Dazu habe ich diese initializeUpdateEverything Action geschrieben:
public function initializeUpdateEverythingAction(){
$propertyMappingConfiguration = $this->arguments->getArgument('types')->getPropertyMappingConfiguration();
$propertyMappingConfiguration->allowProperties('workspace');
$propertyMappingConfiguration->forProperty('workspace')->allowAllProperties();
$propertyMappingConfiguration->allowModificationForSubProperty('workspace');
$types = $this->request->getArgument('types');
foreach($types['workspace'][0] as $workspaceIndex => $workspacePropertyArray){
$propertyPath = 'workspace.*.'.$workspaceIndex;
$propertyMappingConfiguration->forProperty($propertyPath)->allowAllProperties();
$propertyMappingConfiguration->allowCreationForSubProperty($propertyPath);
$propertyMappingConfiguration->allowModificationForSubProperty($propertyPath);
}
}
Ich schaffe es damit aber nicht, das Sub Sub Objekt Instructions zu anzusprechen. Ich kriege immer die Fehlermeldung:
#1297759968: Exception while property mapping at property path "workspace.0":It is not allowed to map property "instructions". You need to use $propertyMappingConfiguration->allowProperties('instructions') to enable mapping of this property.
Wo genau liegt noch der Fehler, oder kann man Sub Sub Objekte nicht mit persistieren?
Vielen Dank Sebastian