|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace MySociety\TheyWorkForYou\DataClass\Regmem; |
|
6
|
|
|
|
|
7
|
|
|
use MySociety\TheyWorkForYou\DataClass\BaseModel; |
|
8
|
|
|
|
|
9
|
|
|
class InfoEntry extends BaseModel { |
|
10
|
|
|
public ?string $id = null; |
|
11
|
|
|
public ?string $comparable_id = null; |
|
12
|
|
|
public string $item_hash; |
|
13
|
|
|
public string $content = ""; |
|
14
|
|
|
public string $content_format = "string"; |
|
15
|
|
|
public string $info_type = "entry"; |
|
16
|
|
|
public bool $null_entry = false; |
|
17
|
|
|
public ?string $date_registered = null; |
|
18
|
|
|
public ?string $date_published = null; |
|
19
|
|
|
public ?string $date_updated = null; |
|
20
|
|
|
public ?string $date_received = null; |
|
21
|
|
|
public ?AnnotationList $annotations = null; |
|
22
|
|
|
public ?DetailGroup $details = null; |
|
23
|
|
|
public ?EntryList $sub_entries = null; |
|
24
|
|
|
|
|
25
|
|
|
public function hasEntries(): bool { |
|
26
|
|
|
return $this->sub_entries !== null && ($this->sub_entries->isEmpty() === false); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function hasDetails(): bool { |
|
30
|
|
|
return $this->details !== null && ($this->details->isEmpty() === false); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
public function hasEntryOrDetail(): bool { |
|
34
|
|
|
return $this->hasEntries() || $this->hasDetails(); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function get_detail(string $slug): ?Detail { |
|
38
|
|
|
// given a slug, return the detail object |
|
39
|
|
|
foreach ($this->details as $detail) { |
|
40
|
|
|
if ($detail->slug === $slug) { |
|
41
|
|
|
return $detail; |
|
42
|
|
|
} |
|
43
|
|
|
} |
|
44
|
|
|
return null; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
} |
|
48
|
|
|
|