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
...@@ -51,6 +51,14 @@ abstract class Entity ...@@ -51,6 +51,14 @@ abstract class Entity
*/ */
protected $authorizedAttributes = []; protected $authorizedAttributes = [];
/**
* Liste des attributs contenant des dates communs à toutes les entités
*/
private $sharedDateTimeAttributes = [
'createTimestamp',
'modifyTimestamp',
];
/** /**
* Liste des attributs contenant des dates * Liste des attributs contenant des dates
* *
...@@ -256,7 +264,7 @@ abstract class Entity ...@@ -256,7 +264,7 @@ abstract class Entity
*/ */
public function get($attrName) 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); $value = $this->getNode()->getDateTimeAttribute($attrName);
} else { } else {
$value = $this->getNode()->getAttribute($attrName); $value = $this->getNode()->getAttribute($attrName);
...@@ -291,7 +299,7 @@ abstract class Entity ...@@ -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)); 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); $this->getNode()->setDateTimeAttribute($attrName, $value, true);
} else { } else {
$this->getNode()->setAttribute($attrName, $value); $this->getNode()->setAttribute($attrName, $value);
...@@ -332,7 +340,7 @@ abstract class Entity ...@@ -332,7 +340,7 @@ abstract class Entity
$this->set($attrName, $value); $this->set($attrName, $value);
} }
else { else {
if (in_array($attrName, $this->dateTimeAttributes)) { if (in_array($attrName, array_merge($this->dateTimeAttributes, $this->sharedDateTimeAttributes))) {
$this->getNode()->appendToDateTimeAttribute($attrName, $value); $this->getNode()->appendToDateTimeAttribute($attrName, $value);
} else { } else {
$this->getNode()->appendToAttribute($attrName, $value); $this->getNode()->appendToAttribute($attrName, $value);
......
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