@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | public function updateCMSFields(FieldList $fields) |
33 | 33 | { |
34 | 34 | $name = ''; |
35 | - if(class_exists($this->getOwner()->ClassNameLastEdited)) { |
|
35 | + if (class_exists($this->getOwner()->ClassNameLastEdited)) { |
|
36 | 36 | $name = Injector::inst()->get($this->getOwner()->ClassNameLastEdited)->i18n_singular_name(); |
37 | 37 | } |
38 | 38 | $fields->addFieldsToTab( |
@@ -43,16 +43,16 @@ discard block |
||
43 | 43 | DatetimeField::create('CacheKeyLastEdited', 'Content Last Edited') |
44 | 44 | ->setRightTitle('The frontend template cache will be invalidated every time this value changes. It changes every time anything is changed in the database.'), |
45 | 45 | ReadonlyField::create('ClassNameLastEdited', 'Last class updated') |
46 | - ->setRightTitle('Last object updated. The name of this object is: '.$name), |
|
46 | + ->setRightTitle('Last object updated. The name of this object is: ' . $name), |
|
47 | 47 | ] |
48 | 48 | ); |
49 | - if($this->getOwner()->RecordCacheUpdates) { |
|
49 | + if ($this->getOwner()->RecordCacheUpdates) { |
|
50 | 50 | $fields->addFieldsToTab( |
51 | 51 | 'Root.Caching', |
52 | 52 | [ |
53 | 53 | GridField::create( |
54 | 54 | 'ObjectsUpdated', |
55 | - 'Last '.self::MAX_OBJECTS_UPDATED.' objects updated', |
|
55 | + 'Last ' . self::MAX_OBJECTS_UPDATED . ' objects updated', |
|
56 | 56 | ObjectsUpdated::get()->limit(self::MAX_OBJECTS_UPDATED), |
57 | 57 | GridFieldConfig_RecordViewer::create() |
58 | 58 | ) |
@@ -64,30 +64,30 @@ discard block |
||
64 | 64 | public static function site_cache_key(): string |
65 | 65 | { |
66 | 66 | $obj = SiteConfig::current_site_config(); |
67 | - if($obj->HasCaching) { |
|
68 | - return (string) 'ts_'.strtotime($obj->CacheKeyLastEdited); |
|
67 | + if ($obj->HasCaching) { |
|
68 | + return (string) 'ts_' . strtotime($obj->CacheKeyLastEdited); |
|
69 | 69 | } else { |
70 | - return (string) 'ts_'.time(); |
|
70 | + return (string) 'ts_' . time(); |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
74 | 74 | public static function update_cache_key(?string $className = '') |
75 | 75 | { |
76 | 76 | $obj = SiteConfig::current_site_config(); |
77 | - if($obj->HasCaching) { |
|
77 | + if ($obj->HasCaching) { |
|
78 | 78 | DB::query(' |
79 | 79 | UPDATE "SiteConfig" |
80 | 80 | SET |
81 | 81 | "CacheKeyLastEdited" = \'' . DBDatetime::now()->Rfc2822() . '\', |
82 | - "ClassNameLastEdited" = \'' . addslashes($className). '\' |
|
83 | - WHERE ID = '.$obj->ID.' |
|
82 | + "ClassNameLastEdited" = \'' . addslashes($className) . '\' |
|
83 | + WHERE ID = '.$obj->ID . ' |
|
84 | 84 | ;'); |
85 | 85 | } |
86 | - if($obj->RecordCacheUpdates) { |
|
86 | + if ($obj->RecordCacheUpdates) { |
|
87 | 87 | $recordId = Injector::inst() |
88 | - ->create(ObjectsUpdated::class, ['ClassNameLastEdited' => $className]) |
|
88 | + ->create(ObjectsUpdated::class, [ 'ClassNameLastEdited' => $className ]) |
|
89 | 89 | ->write(); |
90 | - DB::query('DELETE FROM ObjectsUpdated WHERE ID < '.(Int) ($recordId - self::MAX_OBJECTS_UPDATED)); |
|
90 | + DB::query('DELETE FROM ObjectsUpdated WHERE ID < ' . (Int) ($recordId - self::MAX_OBJECTS_UPDATED)); |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 | } |
@@ -20,9 +20,9 @@ discard block |
||
20 | 20 | // NB. |
21 | 21 | // if the dataobject has the versioned extension then the cache should be invalidated onAfterPublish |
22 | 22 | // hasStages function is part of the Versioned class so safe to check here |
23 | - if (! $owner->hasExtension(Versioned::class)) { |
|
23 | + if (!$owner->hasExtension(Versioned::class)) { |
|
24 | 24 | $this->doUpdateCache($className); |
25 | - } elseif (! $owner->hasStages()) { |
|
25 | + } elseif (!$owner->hasStages()) { |
|
26 | 26 | $this->doUpdateCache($className); |
27 | 27 | } |
28 | 28 | } |
@@ -89,11 +89,11 @@ discard block |
||
89 | 89 | private function canUpdateCache($className): bool |
90 | 90 | { |
91 | 91 | // we want to always avoid this to avoid a loop. |
92 | - if($className === ObjectsUpdated::class) { |
|
92 | + if ($className === ObjectsUpdated::class) { |
|
93 | 93 | return false; |
94 | 94 | } |
95 | 95 | $excludedClasses = (array) Config::inst()->get(self::class, 'excluded_classes_for_caching'); |
96 | 96 | |
97 | - return ! in_array($className, $excludedClasses, true); |
|
97 | + return !in_array($className, $excludedClasses, true); |
|
98 | 98 | } |
99 | 99 | } |