server/src/app/Models/GeoResource.php
changeset 171 f4f558f04f37
parent 169 8fddc113095e
child 277 bd4bc1db4f40
equal deleted inserted replaced
170:31bee084df32 171:f4f558f04f37
    12 
    12 
    13     public function __construct($uri, $graph) {
    13     public function __construct($uri, $graph) {
    14         parent::__construct($uri, $graph);
    14         parent::__construct($uri, $graph);
    15     }
    15     }
    16 
    16 
    17     private $refLoc = false;
    17     private $refLocs = null;
    18     private $notes = null;
    18     private $notes = null;
    19 
    19 
    20     public function clearMemoizationCache() {
    20     public function clearMemoizationCache() {
    21         $this->refLoc = false;
    21         $this->refLocs = null;
    22         $this->notes = null;
    22         $this->notes = null;
    23     }
    23     }
    24 
    24 
    25     public function getRefLoc() {
    25     public function getRefLocs() {
    26         if($this->refLoc === false) {
    26         if(is_null($this->refLocs)) {
    27             $refLoc = $this->getResource("<http://www.w3.org/2002/07/owl#sameAs>");
    27             $refLocs = $this->allResources("<http://www.w3.org/2002/07/owl#sameAs>");
    28             $this->refLoc = is_null($refLoc)?null:$refLoc->getUri();
    28             $this->refLocs = array_map(function($refLoc) { return $refLoc->getUri();}, $refLocs);
    29         }
    29         }
    30         return $this->refLoc;
    30         return $this->refLocs;
    31     }
    31     }
    32 
    32 
    33     public function getNotes() {
    33     public function getNotes() {
    34         if(is_null($this->notes)) {
    34         if(is_null($this->notes)) {
    35             $this->notes = $this->all('<http://www.w3.org/2004/02/skos/core#note>');
    35             $this->notes = $this->all('<http://www.w3.org/2004/02/skos/core#note>');
    41         $notes = array_map(
    41         $notes = array_map(
    42             function($note) { return Utils::processLiteralResourceOrString($note); },
    42             function($note) { return Utils::processLiteralResourceOrString($note); },
    43             $this->getNotes()
    43             $this->getNotes()
    44         );
    44         );
    45         return [
    45         return [
    46             'ref-loc' => $this->getRefLoc(),
    46             'ref-locs' => $this->getRefLocs(),
    47             'notes' => $notes
    47             'notes' => $notes
    48         ];
    48         ];
    49     }
    49     }
    50 
    50 
    51 }
    51 }