public function getDataFromEditmode($data, $object = null, $params = [])
{
$container = $this->getDataFromObjectParam($object);
if (empty($container)) {
$className = $object->getClass()->getName();
$containerClass = "\\Pimcore\\Model\\Object\\" . ucfirst($className) . "\\" . ucfirst($this->getName());
$container = new $containerClass($object, $this->getName());
}
if (is_array($data)) {
foreach ($data as $collectionRaw) {
$collectionData = [];
$collectionDef = Object\Objectbrick\Definition::getByKey($collectionRaw["type"]);
$getter = "get" . ucfirst($collectionRaw["type"]);
$brick = $container->{$getter}();
if (empty($brick)) {
$brickClass = "\\Pimcore\\Model\\Object\\Objectbrick\\Data\\" . ucfirst($collectionRaw["type"]);
$brick = new $brickClass($object);
}
if ($collectionRaw["data"] == "deleted") {
$brick->setDoDelete(true);
} else {
foreach ($collectionDef->getFieldDefinitions() as $fd) {
if (array_key_exists($fd->getName(), $collectionRaw["data"])) {
$collectionData[$fd->getName()] = $fd->getDataFromEditmode($collectionRaw["data"][$fd->getName()], $object);
}
}
$brick->setValues($collectionData);
$brick->setFieldname($this->getName());
$setter = "set" . ucfirst($collectionRaw["type"]);
$container->{$setter}($brick);
}
}
}
return $container;
}