Passed
Push — master ( 16e851...25995c )
by Daniel
09:34
created

RuleController::disabledaction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SilverStripe\Control\Tests\HTTPCacheControlIntegrationTest;
4
5
use SilverStripe\Control\Controller;
6
use SilverStripe\Control\Middleware\HTTPCacheControlMiddleware;
7
use SilverStripe\Dev\TestOnly;
8
9
class RuleController extends Controller implements TestOnly
10
{
11
    private static $url_segment = 'HTTPCacheControlIntegrationTest_RuleController';
0 ignored issues
show
introduced by
The private property $url_segment is not used, and could be removed.
Loading history...
12
13
    private static $allowed_actions = [
0 ignored issues
show
introduced by
The private property $allowed_actions is not used, and could be removed.
Loading history...
14
        'privateaction',
15
        'publicaction',
16
        'disabledaction',
17
    ];
18
19
    protected function init()
20
    {
21
        parent::init();
22
        // Prefer public by default
23
        HTTPCacheControlMiddleware::singleton()->publicCache();
24
    }
25
26
    public function privateaction()
27
    {
28
        HTTPCacheControlMiddleware::singleton()->privateCache();
29
        return 'private content';
30
    }
31
32
    public function publicaction()
33
    {
34
        HTTPCacheControlMiddleware::singleton()
35
            ->publicCache()
36
            ->setMaxAge(9000);
37
        return 'public content';
38
    }
39
40
    public function disabledaction()
41
    {
42
        HTTPCacheControlMiddleware::singleton()->disableCache();
43
        return 'uncached content';
44
    }
45
}
46