public function getDataFromEditmode($data, $object = null, $params = [])
{
$class = $object->getClass();
$objectId = $object->getId();
$pairs = [];
foreach ($data as $pair) {
// $key = $pair["key"];
if ($pair["mandatory"]) {
$value = $pair["value"];
if ($pair["type"] == "number") {
if (is_null($value) || $value === "") {
throw new \Exception("Mandatory key " . $pair["key"]);
}
} elseif ($pair["type"] == "text" || $pair["type"] == "translated" || $pair["type"] == "select") {
if (!strlen((string) $value)) {
throw new \Exception("Mandatory key " . $pair["key"]);
}
}
}
$pairs[] = $pair;
}
$keyValue = new Object\Data\KeyValue();
$keyValue->setObjectId($objectId);
$keyValue->setProperties($pairs);
return $keyValue;
}