|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SilverStripe\SiteWideContentReport\Model; |
|
4
|
|
|
|
|
5
|
|
|
use SilverStripe\Subsites\Model\Subsite; |
|
|
|
|
|
|
6
|
|
|
use SilverStripe\Core\Extension; |
|
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('SitewideContentReport.MainSite', 'Main Site'); |
|
33
|
|
|
if ($itemType !== 'Pages') { |
|
34
|
|
|
$mainSiteLabel .= ' '._t('SitewideContentReport.AccessFromAllSubsites', '(accessible by all subsites)'); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
// Add subsite name |
|
38
|
|
|
$columns['SubsiteName'] = [ |
|
39
|
|
|
'title' => _t('SitewideContentReport.Subsite', 'Subsite'), |
|
40
|
|
|
'datasource' => function ($item) use ($mainSiteLabel) { |
|
41
|
|
|
$subsite = $item->Subsite(); |
|
42
|
|
|
|
|
43
|
|
|
if ($subsite && $subsite->exists() && $subsite->Title) { |
|
44
|
|
|
return $subsite->Title; |
|
45
|
|
|
} else { |
|
46
|
|
|
return $mainSiteLabel; |
|
47
|
|
|
} |
|
48
|
|
|
}, |
|
49
|
|
|
]; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @param $total |
|
54
|
|
|
* @param $index |
|
55
|
|
|
* @param $record |
|
56
|
|
|
* @param $attributes |
|
57
|
|
|
*/ |
|
58
|
|
|
public function updateRowAttributes($total, $index, $record, &$attributes) |
|
|
|
|
|
|
59
|
|
|
{ |
|
60
|
|
|
$attributes['data-subsite-id'] = $record->SubsiteID; |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|
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