Commit 32126161 authored by David Surville's avatar David Surville
Browse files

Mise à jour des fonctions setUnicaenTermsOfUse et setSupannRefId

parent a8c7f080
......@@ -1513,6 +1513,10 @@ class People extends Entity
{
$value = $this->preFormat($value);
if(empty($value)) {
$this->appendOrNot('supannRefId', $value, $append);
}
foreach ($value as $v) {
if (preg_match(self::$attribute_with_label_pattern, $v, $matches)) {
if ($append) {
......@@ -1573,7 +1577,34 @@ class People extends Entity
public function setUnicaenTermsOfUse($value = null, $append = false)
{
$value = $this->preFormat($value);
$this->appendOrNot('unicaenTermsOfUse', $value, $append);
if(empty($value)) {
$this->appendOrNot('unicaenTermsOfUse', $value, $append);
}
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'];
$currentValues = $this->preFormat($this->unicaenTermsOfUse);
array_walk($currentValues, function (&$cv) use ($label, $identifiant) {
if (preg_match("/^".$label."(?<identifiant>.+)$/", $cv, $matches)) {
if($matches['identifiant'] != $identifiant) {
$this->remove('unicaenTermsOfUse', $cv);
$cv = null;
}
}
});
if(!in_array($v, $currentValues)) {
$currentValues[] = $v;
}
$this->appendOrNot('unicaenTermsOfUse', array_filter($currentValues), false);
}
}
}
return $this;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment