1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SilverStripe\SiteWideContentReport\Model; |
4
|
|
|
|
5
|
|
|
use SilverStripe\Core\Config\Config; |
6
|
|
|
use SilverStripe\Core\Extension; |
7
|
|
|
use SilverStripe\Taxonomy\TaxonomyTerm; |
|
|
|
|
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Provides taxonomy integration for sitewide content report. |
11
|
|
|
* |
12
|
|
|
* Requires https://github.com/silverstripe-labs/silverstripe-taxonomy |
13
|
|
|
* |
14
|
|
|
* Class SitewideContentTaxonomy |
15
|
|
|
* @package SilverStripe\SiteWideContentReport\Model |
16
|
|
|
*/ |
17
|
|
|
class SitewideContentTaxonomy extends Extension |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* Name of field to get tags from. |
21
|
|
|
* |
22
|
|
|
* @config |
23
|
|
|
* |
24
|
|
|
* @var string |
25
|
|
|
*/ |
26
|
|
|
private static $tag_field = 'Terms'; |
|
|
|
|
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Update columns to include taxonomy details. |
30
|
|
|
* |
31
|
|
|
* @param string $itemType (i.e 'Pages' or 'Files') |
32
|
|
|
* @param array $columns Columns |
33
|
|
|
*/ |
34
|
|
|
public function updateColumns($itemType, &$columns) |
35
|
|
|
{ |
36
|
|
|
if ($itemType !== 'Pages') { |
37
|
|
|
return; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
// Check if pages has the tags field |
41
|
|
|
if (!self::enabled()) { |
42
|
|
|
return; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
// Set column |
46
|
|
|
$field = Config::inst()->get(__CLASS__, 'tag_field'); |
47
|
|
|
$columns['Terms'] = [ |
48
|
|
|
'printonly' => true, // Hide on page report |
49
|
|
|
'title' => _t('SilverStripe\\SiteWideContentReport\\SitewideContentReport.Tags', 'Tags'), |
50
|
|
|
'datasource' => function ($record) use ($field) { |
51
|
|
|
$tags = $record->$field()->column('Name'); |
52
|
|
|
|
53
|
|
|
return implode(', ', $tags); |
54
|
|
|
}, |
55
|
|
|
]; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Check if this field is enabled. |
60
|
|
|
* |
61
|
|
|
* @return bool |
62
|
|
|
*/ |
63
|
|
|
public static function enabled() |
64
|
|
|
{ |
65
|
|
|
if (!class_exists(TaxonomyTerm::class)) { |
66
|
|
|
return false; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
// Check if pages has the tags field |
70
|
|
|
$field = Config::inst()->get(__CLASS__, 'tag_field'); |
71
|
|
|
|
72
|
|
|
return singleton('Page')->hasMethod($field); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
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