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

Mise à jour des fonctions setUnicaenTermsOfUse et setSupannRefId

parent f6814785
No related branches found
No related tags found
No related merge requests found
......@@ -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);
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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment