1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Sunnysideup\SimpleTemplateCaching\Model; |
4
|
|
|
|
5
|
|
|
use SilverStripe\Core\Injector\Injector; |
6
|
|
|
use SilverStripe\ORM\DataObject; |
7
|
|
|
use SilverStripe\ORM\DB; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* A blog category for generalising blog posts. |
11
|
|
|
* |
12
|
|
|
* @property string $ClassNameLastEdited |
13
|
|
|
*/ |
14
|
|
|
class ObjectsUpdated extends DataObject |
15
|
|
|
{ |
16
|
|
|
|
17
|
|
|
public static function classes_edited(): string |
18
|
|
|
{ |
19
|
|
|
$query = DB::query('SELECT DISTINCT ClassNameLastEdited FROM ObjectsUpdated ORDER BY ClassNameLastEdited ASC'); |
20
|
|
|
foreach ($query as $row) { |
21
|
|
|
$array[$row['ClassNameLastEdited']] = Injector::inst()->get($row['ClassNameLastEdited'])->i18n_singular_name(); |
22
|
|
|
} |
23
|
|
|
return implode(', ', $array); |
|
|
|
|
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
private static $table_name = 'ObjectsUpdated'; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var array |
33
|
|
|
*/ |
34
|
|
|
private static $db = [ |
35
|
|
|
'ClassNameLastEdited' => 'Varchar(255)', |
36
|
|
|
]; |
37
|
|
|
|
38
|
|
|
private static $default_sort = [ |
39
|
|
|
'ID' => 'DESC', |
40
|
|
|
]; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var array |
44
|
|
|
*/ |
45
|
|
|
private static $summary_fields = [ |
46
|
|
|
'Created' => 'Updated', |
47
|
|
|
'Title' => 'Record name ', |
48
|
|
|
'LastEdited' => 'Last Edited', |
49
|
|
|
]; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var array |
53
|
|
|
*/ |
54
|
|
|
private static $field_labels = [ |
55
|
|
|
'Created' => 'Updated', |
56
|
|
|
'Title' => 'Human readable name', |
57
|
|
|
'LastEdited' => 'Code name', |
58
|
|
|
]; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @var array |
62
|
|
|
*/ |
63
|
|
|
private static $casting = [ |
64
|
|
|
'Title' => 'Varchar', |
65
|
|
|
]; |
66
|
|
|
|
67
|
|
|
public function getTitle(): string |
68
|
|
|
{ |
69
|
|
|
if (class_exists((string) $this->ClassNameLastEdited)) { |
70
|
|
|
return Injector::inst()->get($this->ClassNameLastEdited)->i18n_singular_name(); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
return 'ERROR: class not found'; |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|