Passed
Push — master ( 816fb0...a5ac58 )
by Nicolaas
03:07
created
src/Extensions/SimpleTemplateCachingSiteConfigExtension.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
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(
@@ -44,16 +44,16 @@  discard block
 block discarded – undo
44 44
                 ReadonlyField::create('CacheKeyLastEdited', 'Content Last Edited')
45 45
                     ->setRightTitle('The frontend template cache will be invalidated every time this value changes. It changes every time anything is changed in the database.'),
46 46
                 ReadonlyField::create('ClassNameLastEdited', 'Last class updated')
47
-                    ->setRightTitle('Last object updated. The name of this object is: '.$name),
47
+                    ->setRightTitle('Last object updated. The name of this object is: ' . $name),
48 48
             ]
49 49
         );
50
-        if($this->getOwner()->RecordCacheUpdates) {
50
+        if ($this->getOwner()->RecordCacheUpdates) {
51 51
             $fields->addFieldsToTab(
52 52
                 'Root.Caching',
53 53
                 [
54 54
                     GridField::create(
55 55
                         'ObjectsUpdated',
56
-                        'Last '.self::MAX_OBJECTS_UPDATED.' objects updated',
56
+                        'Last ' . self::MAX_OBJECTS_UPDATED . ' objects updated',
57 57
                         ObjectsUpdated::get()->limit(self::MAX_OBJECTS_UPDATED),
58 58
                         GridFieldConfig_RecordViewer::create()
59 59
                     )
@@ -65,30 +65,30 @@  discard block
 block discarded – undo
65 65
     public static function site_cache_key(): string
66 66
     {
67 67
         $obj = SiteConfig::current_site_config();
68
-        if($obj->HasCaching) {
69
-            return (string) 'ts_'.strtotime($obj->CacheKeyLastEdited);
68
+        if ($obj->HasCaching) {
69
+            return (string) 'ts_' . strtotime($obj->CacheKeyLastEdited);
70 70
         } else {
71
-            return  (string) 'ts_'.time();
71
+            return  (string) 'ts_' . time();
72 72
         }
73 73
     }
74 74
 
75 75
     public static function update_cache_key(?string $className = '')
76 76
     {
77 77
         $obj = SiteConfig::current_site_config();
78
-        if($obj->HasCaching) {
78
+        if ($obj->HasCaching) {
79 79
             DB::query('
80 80
                 UPDATE "SiteConfig"
81 81
                 SET
82 82
                     "CacheKeyLastEdited" = \'' . DBDatetime::now()->Rfc2822() . '\',
83
-                    "ClassNameLastEdited" = \'' . addslashes($className). '\'
84
-                WHERE ID = '.$obj->ID.'
83
+                    "ClassNameLastEdited" = \'' . addslashes($className) . '\'
84
+                WHERE ID = '.$obj->ID . '
85 85
             ;');
86 86
         }
87
-        if($obj->RecordCacheUpdates) {
87
+        if ($obj->RecordCacheUpdates) {
88 88
             $recordId = Injector::inst()
89
-                ->create(ObjectsUpdated::class, ['ClassNameLastEdited' => $className])
89
+                ->create(ObjectsUpdated::class, [ 'ClassNameLastEdited' => $className ])
90 90
                 ->write();
91
-            DB::query('DELETE FROM ObjectsUpdated WHERE ID < '.(Int) ($recordId - self::MAX_OBJECTS_UPDATED));
91
+            DB::query('DELETE FROM ObjectsUpdated WHERE ID < ' . (Int) ($recordId - self::MAX_OBJECTS_UPDATED));
92 92
         }
93 93
     }
94 94
 }
Please login to merge, or discard this patch.