Skip to content
Snippets Groups Projects
Commit 3543f1b2 authored by David Surville's avatar David Surville
Browse files

[Fix] Les fonctions setUnicaenTermsOfUse et setSupannRefId géraient mal la...

[Fix] Les fonctions setUnicaenTermsOfUse et setSupannRefId géraient mal la modification multi-valuée pour une même étiquette
parent 32126161
No related branches found
No related tags found
No related merge requests found
......@@ -1514,31 +1514,37 @@ class People extends Entity
$value = $this->preFormat($value);
if(empty($value)) {
$this->appendOrNot('supannRefId', $value, $append);
$this->appendOrNot('supannRefId', $value, false);
}
if ($append) {
$this->appendOrNot('supannRefId', $value, true);
}
$newValues = [];
foreach ($value as $v) {
if (preg_match(self::$attribute_with_label_pattern, $v, $matches)) {
if ($append) {
$this->appendOrNot('supannRefId', $v, true);
} else {
$label = $matches['etiquette'];
$identifiant = $matches['identifiant'];
$newValues[$matches['etiquette']][] = $matches['identifiant'];
}
};
foreach ($newValues as $label => $values) {
$currentValues = $this->preFormat($this->supannRefId);
array_walk($currentValues, function (&$cv) use ($label, $identifiant) {
array_walk($currentValues, function (&$cv) use ($label, $values) {
if (preg_match("/^".$label."(?<identifiant>.+)$/", $cv, $matches)) {
if($matches['identifiant'] != $identifiant) {
if(!in_array($matches['identifiant'], $values)) {
$this->remove('supannRefId', $cv);
$cv = null;
}
}
});
foreach($values as $v) {
$v = $label.$v;
if (!in_array($v, $currentValues)) {
$currentValues[] = $v;
}
$this->appendOrNot('supannRefId', array_filter($currentValues), false);
}
}
$this->appendOrNot('supannRefId', array_filter($currentValues), false);
}
return $this;
......@@ -1579,31 +1585,37 @@ class People extends Entity
$value = $this->preFormat($value);
if(empty($value)) {
$this->appendOrNot('unicaenTermsOfUse', $value, $append);
$this->appendOrNot('unicaenTermsOfUse', $value, false);
}
if ($append) {
$this->appendOrNot('unicaenTermsOfUse', $value, true);
}
$newValues = [];
foreach ($value as $v) {
if (preg_match(self::$attribute_with_label_pattern, $v, $matches)) {
if ($append) {
$this->appendOrNot('unicaenTermsOfUse', $v, true);
} else {
$label = $matches['etiquette'];
$identifiant = $matches['identifiant'];
$newValues[$matches['etiquette']][] = $matches['identifiant'];
}
};
foreach ($newValues as $label => $values) {
$currentValues = $this->preFormat($this->unicaenTermsOfUse);
array_walk($currentValues, function (&$cv) use ($label, $identifiant) {
array_walk($currentValues, function (&$cv) use ($label, $values) {
if (preg_match("/^".$label."(?<identifiant>.+)$/", $cv, $matches)) {
if($matches['identifiant'] != $identifiant) {
if(!in_array($matches['identifiant'], $values)) {
$this->remove('unicaenTermsOfUse', $cv);
$cv = null;
}
}
});
foreach($values as $v) {
$v = $label.$v;
if (!in_array($v, $currentValues)) {
$currentValues[] = $v;
}
$this->appendOrNot('unicaenTermsOfUse', array_filter($currentValues), false);
}
}
$this->appendOrNot('unicaenTermsOfUse', array_filter($currentValues), false);
}
return $this;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment