Passed
Push — master ( dde6cc...887c42 )
by Nicolaas
03:51
created

CachedPages::columns()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 17
rs 10
1
<?php
2
3
namespace Sunnysideup\SimpleTemplateCaching\Reports;
4
5
use Page;
0 ignored issues
show
Bug introduced by
The type Page was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use SilverStripe\CMS\Model\RedirectorPage;
7
use SilverStripe\CMS\Model\SiteTree;
8
use SilverStripe\ORM\DataList;
9
use SilverStripe\Reports\Report;
10
11
class CachedPages extends Report
12
{
13
    public function title()
14
    {
15
        return 'Pages with caching';
16
    }
17
18
    public function group()
19
    {
20
        return _t(__CLASS__ . '.ContentGroupTitle', "Content reports");
21
    }
22
23
    public function sort()
24
    {
25
        return 100;
26
    }
27
28
    /**
29
     * Gets the source records
30
     *
31
     * @param array $params
32
     * @return DataList<SiteTree>
33
     */
34
    public function sourceRecords($params = null)
35
    {
36
        return Page::get()
37
            ->filter(['PublicCacheDurationInSeconds:GreaterThan' => 0, 'NeverCachePublicly' => 0]);
38
    }
39
40
    public function columns()
41
    {
42
        return [
43
            "Title" => [
44
                "title" => "Title",
45
                "link" => true,
46
            ],
47
            // 'ShowInMenus' => [
48
            //     'title' => 'Cache Link',
49
            //     'formatting' => function ($value, $item) {
50
            //         return '<a href="' . $item->Link() . '?flush=all" target="_blank">Flush Cache</a>';
51
            //     },
52
            // ],
53
            'ShowInSearch' => [
54
                'title' => 'Edit Cache Settings',
55
                'formatting' => function ($value, $item) {
56
                    return '<a href="' . $item->EditCacheSettingsLink() . '" target="_blank">Edit Settings</a>';
57
                },
58
            ],
59
        ];
60
    }
61
}
62