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

"[Evolution] Ajout des attributs \"createTimestamp\" et \"modifyTimestamp\"...

"[Evolution] Ajout des attributs \"createTimestamp\" et \"modifyTimestamp\" comme DateTimeAttributes
parent de924209
Loading
Loading
Loading
Loading
+11 −3
Changes for src/UnicaenLdap/Entity/Entity.php: 11 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -51,6 +51,14 @@ abstract class Entity
     */
    protected $authorizedAttributes = [];

    /**
     * Liste des attributs contenant des dates communs à toutes les entités
     */
    private $sharedDateTimeAttributes = [
        'createTimestamp',
        'modifyTimestamp',
    ];

    /**
     * Liste des attributs contenant des dates
     *
@@ -256,7 +264,7 @@ abstract class Entity
     */
    public function get($attrName)
    {
        if (in_array($attrName, $this->dateTimeAttributes)) {
        if (in_array($attrName, array_merge($this->dateTimeAttributes, $this->sharedDateTimeAttributes))) {
            $value = $this->getNode()->getDateTimeAttribute($attrName);
        } else {
            $value = $this->getNode()->getAttribute($attrName);
@@ -291,7 +299,7 @@ abstract class Entity
            throw new Exception(sprintf("L'attribut Ldap '%s' est monovalué et ne doit contenir qu'une seule valeur.", $attrName));
        }

        if (in_array($attrName, $this->dateTimeAttributes)) {
        if (in_array($attrName, array_merge($this->dateTimeAttributes, $this->sharedDateTimeAttributes))) {
            $this->getNode()->setDateTimeAttribute($attrName, $value, true);
        } else {
            $this->getNode()->setAttribute($attrName, $value);
@@ -332,7 +340,7 @@ abstract class Entity
            $this->set($attrName, $value);
        }
        else {
            if (in_array($attrName, $this->dateTimeAttributes)) {
            if (in_array($attrName, array_merge($this->dateTimeAttributes, $this->sharedDateTimeAttributes))) {
                $this->getNode()->appendToDateTimeAttribute($attrName, $value);
            } else {
                $this->getNode()->appendToAttribute($attrName, $value);