equal
deleted
inserted
replaced
|
1 <?php |
|
2 namespace CorpusParole\Models; |
|
3 |
|
4 use CorpusParole\Libraries\RdfModel\RdfModelResource; |
|
5 use JsonSerializable; |
|
6 use Log; |
|
7 |
|
8 /** |
|
9 * Model class for Document. Inherit from EasyRd\Resource |
|
10 * SELECT DISTINCT ?g WHERE {GRAPH ?g {?s ?p ?o}} |
|
11 */ |
|
12 abstract class WebResource extends RdfModelResource implements JsonSerializable { |
|
13 |
|
14 public function __construct(...$args) { |
|
15 list($uri, $graph) = $args; |
|
16 parent::__construct($uri, $graph); |
|
17 } |
|
18 |
|
19 private $format = -1; |
|
20 |
|
21 abstract protected function doClearMemoizationCache(); |
|
22 |
|
23 public function clearMemoizationCache() { |
|
24 $this->format = -1; |
|
25 $this->doClearMemoizationCache(); |
|
26 } |
|
27 |
|
28 public function getFormat() { |
|
29 if($this->format === -1) { |
|
30 $format = $this->getLiteral("<http://purl.org/dc/elements/1.1/format>"); |
|
31 $this->format = is_null($format)?null:$format->getValue(); |
|
32 } |
|
33 return $this->format; |
|
34 } |
|
35 |
|
36 public function getUrl() { |
|
37 return $this->getUri(); |
|
38 } |
|
39 |
|
40 abstract protected function jsonSerializeExtra(); |
|
41 |
|
42 public function jsonSerialize() { |
|
43 return array_merge( |
|
44 [ |
|
45 'url' => $this->getUrl(), |
|
46 'format' => $this->getFormat() |
|
47 ], |
|
48 $this->jsonSerializeExtra() |
|
49 ); |
|
50 } |
|
51 |
|
52 } |