Passed
Push — master ( 8ab115...ba85c8 )
by Nicolaas
10:27
created

PageExtension   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 23
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A updateSettingsFields() 0 16 1
1
<?php
2
3
namespace Sunnysideup\SimpleTemplateCaching\Extensions;
4
5
use SilverStripe\Forms\CheckboxField;
6
use SilverStripe\Forms\FieldList;
7
use SilverStripe\Forms\NumericField;
8
use SilverStripe\ORM\DataExtension;
9
use SilverStripe\SiteConfig\SiteConfig;
10
11
/**
12
 * Class \Sunnysideup\SimpleTemplateCaching\Extensions\PageExtension.
13
 *
14
 * @property Page|PageExtension $owner
15
 * @property bool $NeverCachePublicly
16
 * @property bool $PublicCacheDurationInSeconds
17
 */
18
class PageExtension extends DataExtension
19
{
20
    private static $db = [
21
        'NeverCachePublicly' => 'Boolean',
22
        'PublicCacheDurationInSeconds' => 'Boolean',
23
    ];
24
25
    public function updateSettingsFields(FieldList $fields)
26
    {
27
        $fields->addFieldsToTab(
28
            'Root.Cache',
29
            [
30
                CheckboxField::create('NeverCachePublicly', 'Never cache this page publicly (so that all users see the same page)'),
31
                NumericField::create(
32
                    'PublicCacheDurationInSeconds',
33
                    'Number of caching seconds for public users (0 = no caching)'
34
                )
35
                    ->setDescription(
36
                        '
37
                        Use with care!
38
                        This should only be used on pages that should be the same for all users and that should be accessible publicly.
39
                        You can also set this value <a href="/admin/settings#Root_Caching">for the whole site</a> .
40
                        The current value is ' . SiteConfig::current_site_config()->PublicCacheDurationInSeconds . ' seconds.'
41
                    ),
42
43
            ]
44
        );
45
    }
46
}
47