1 | <?php |
||||||
2 | |||||||
3 | namespace SilverStripe\SiteWideContentReport\Model; |
||||||
4 | |||||||
5 | use SilverStripe\Core\Extension; |
||||||
6 | use SilverStripe\Subsites\Model\Subsite; |
||||||
0 ignored issues
–
show
|
|||||||
7 | |||||||
8 | /** |
||||||
9 | * Provides subsite integration for sitewide content report. |
||||||
10 | * |
||||||
11 | * Requires https://github.com/silverstripe/silverstripe-subsites |
||||||
12 | * |
||||||
13 | * Class SitewideContentSubsites |
||||||
14 | * @package SilverStripe\SiteWideContentReport\Model |
||||||
15 | */ |
||||||
16 | class SitewideContentSubsites extends Extension |
||||||
17 | { |
||||||
18 | /** |
||||||
19 | * Update columns to include subsite details. |
||||||
20 | * |
||||||
21 | * @param string $itemType (i.e 'Pages' or 'Files') |
||||||
22 | * @param array $columns Columns |
||||||
23 | */ |
||||||
24 | public function updateColumns($itemType, &$columns) |
||||||
25 | { |
||||||
26 | // Skip single subsite setups |
||||||
27 | if (!Subsite::get()->count()) { |
||||||
28 | return; |
||||||
29 | } |
||||||
30 | |||||||
31 | // Set title |
||||||
32 | $mainSiteLabel = _t('SilverStripe\\SiteWideContentReport\\SitewideContentReport.MainSite', 'Main Site'); |
||||||
33 | if ($itemType !== 'Pages') { |
||||||
34 | $mainSiteLabel .= ' '._t( |
||||||
35 | 'SilverStripe\\SiteWideContentReport\\SitewideContentReport.AccessFromAllSubsites', |
||||||
36 | '(accessible by all subsites)' |
||||||
37 | ); |
||||||
38 | } |
||||||
39 | |||||||
40 | // Add subsite name |
||||||
41 | $columns['SubsiteName'] = [ |
||||||
42 | 'title' => _t('SilverStripe\\SiteWideContentReport\\SitewideContentReport.Subsite', 'Subsite'), |
||||||
43 | 'datasource' => function ($item) use ($mainSiteLabel) { |
||||||
44 | $subsite = $item->Subsite(); |
||||||
45 | |||||||
46 | if ($subsite && $subsite->exists() && $subsite->Title) { |
||||||
47 | return $subsite->Title; |
||||||
48 | } else { |
||||||
49 | return $mainSiteLabel; |
||||||
50 | } |
||||||
51 | }, |
||||||
52 | ]; |
||||||
53 | } |
||||||
54 | |||||||
55 | /** |
||||||
56 | * @param $total |
||||||
57 | * @param $index |
||||||
58 | * @param $record |
||||||
59 | * @param $attributes |
||||||
60 | */ |
||||||
61 | public function updateRowAttributes($total, $index, $record, &$attributes) |
||||||
0 ignored issues
–
show
The parameter
$total is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() The parameter
$index is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||||
62 | { |
||||||
63 | $attributes['data-subsite-id'] = $record->SubsiteID; |
||||||
64 | } |
||||||
65 | } |
||||||
66 |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths