Commit 2eeb3421 authored by David Surville's avatar David Surville
Browse files

Ajout de la fonction getReferentielId() qui renvoie l'identifiant Octopus pour...

Ajout de la fonction getReferentielId() qui renvoie l'identifiant Octopus pour les structures et les groupes
parent 5db221db
Loading
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -53,4 +53,23 @@ class Group extends BaseGroup

        return $result;
    }

    /**
     * Retourne l'identifiant du groupe dans le référentiel
     *
     * @return string|null
     */
    public function getReferentielId()
    {
        $attributeValues = $this->preFormat($this->supannRefId);
        $label = $this->getLabel('OCTOPUS', 'ID');

        $value = array_filter($attributeValues, function ($v) use ($label) {
            return preg_match("/^$label(?<identifiant>.+)$/", $v);
        });

        return !empty($value)
            ? str_replace($label, '', array_values($value)[0])
            : null;
    }
}
 No newline at end of file
+19 −0
Original line number Diff line number Diff line
@@ -65,4 +65,23 @@ class Structure extends BaseStructure
            ? substr($code, 3)
            : $code;
    }

    /**
     * Retourne l'identifiant de la structure dans le référentiel
     *
     * @return string|null
     */
    public function getReferentielId()
    {
        $attributeValues = $this->preFormat($this->supannRefId);
        $label = $this->getLabel('OCTOPUS', 'ID');

        $value = array_filter($attributeValues, function ($v) use ($label) {
            return preg_match("/^$label(?<identifiant>.+)$/", $v);
        });

        return !empty($value)
            ? str_replace($label, '', array_values($value)[0])
            : null;
    }
}
 No newline at end of file