server/src/app/Models/DocumentBase.php
changeset 325 31a4987f6017
parent 260 64caee7ce38d
child 326 226d5b17a119
equal deleted inserted replaced
324:92fc9d077f95 325:31a4987f6017
    26     // memoization
    26     // memoization
    27     private $providedCHO = null;
    27     private $providedCHO = null;
    28     private $title = false;
    28     private $title = false;
    29     private $lang = null;
    29     private $lang = null;
    30     private $langResolved = null;
    30     private $langResolved = null;
    31     private $issued = null;
    31     private $issued = false;
    32     private $modified = null;
    32     private $modified = false;
       
    33     private $created = false;
    33 
    34 
    34 
    35 
    35     public function getProvidedCHO() {
    36     public function getProvidedCHO() {
    36         if(is_null($this->providedCHO)) {
    37         if(is_null($this->providedCHO)) {
    37             $this->providedCHO = $this->get("<http://www.europeana.eu/schemas/edm/aggregatedCHO>");
    38             $this->providedCHO = $this->get("<http://www.europeana.eu/schemas/edm/aggregatedCHO>");
    42     protected function clearMemoizationCache() {
    43     protected function clearMemoizationCache() {
    43         $this->providedCHO = null;
    44         $this->providedCHO = null;
    44         $this->title = false;
    45         $this->title = false;
    45         $this->lang = null;
    46         $this->lang = null;
    46         $this->langResolved = null;
    47         $this->langResolved = null;
    47         $this->issued = null;
    48         $this->issued = false;
    48         $this->modified = null;
    49         $this->modified = false;
       
    50         $this->created = false;
    49     }
    51     }
    50 
    52 
    51     public function getId() {
    53     public function getId() {
    52         if(is_null($this->id)) {
    54         if(is_null($this->id)) {
    53             $ids = $this->getProvidedCHO()->all('<http://purl.org/dc/elements/1.1/identifier>');
    55             $ids = $this->getProvidedCHO()->all('<http://purl.org/dc/elements/1.1/identifier>');
   123         $title = $this->getTitle();
   125         $title = $this->getTitle();
   124         return is_null($title)?null:$title->getValue();
   126         return is_null($title)?null:$title->getValue();
   125     }
   127     }
   126 
   128 
   127     public function getIssued() {
   129     public function getIssued() {
   128         if(is_null($this->issued)) {
   130         if($this->issued === false) {
   129             try {
   131             try {
   130                 $this->issued = $this->getProvidedCHO()->getLiteral("<http://purl.org/dc/terms/issued>");
   132                 $this->issued = $this->getProvidedCHO()->getLiteral("<http://purl.org/dc/terms/issued>");
   131             } catch(\Exception $e) {
   133             } catch(\Exception $e) {
   132                 $this->issued = null;
   134                 $this->issued = null;
   133             }
   135             }
   138     public function getIssuedValue() {
   140     public function getIssuedValue() {
   139         $issued = $this->getIssued();
   141         $issued = $this->getIssued();
   140         return is_null($issued)?null:$issued->getValue();
   142         return is_null($issued)?null:$issued->getValue();
   141     }
   143     }
   142 
   144 
       
   145     public function getCreated() {
       
   146         if($this->created === false) {
       
   147             try {
       
   148                 $this->created = $this->getProvidedCHO()->getLiteral("<http://purl.org/dc/terms/created>");
       
   149             } catch(\Exception $e) {
       
   150                 $this->created = null;
       
   151             }
       
   152         }
       
   153         return $this->created;
       
   154     }
       
   155 
   143     public function getModified() {
   156     public function getModified() {
   144         if(is_null($this->modified)) {
   157         if($this->modified === false) {
   145             try {
   158             try {
   146                 $this->modified = $this->getProvidedCHO()->getLiteral("<http://purl.org/dc/terms/modified>");
   159                 $this->modified = $this->getProvidedCHO()->getLiteral("<http://purl.org/dc/terms/modified>");
   147                 if(is_null($this->modified)) {
   160                 if(is_null($this->modified)) {
   148                     $this->modified = $this->getIssued();
   161                     $this->modified = $this->getIssued();
   149                 }
   162                 }