1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SilverStripe\VersionedAdmin\Extensions; |
4
|
|
|
|
5
|
|
|
use DNADesign\Elemental\Models\BaseElement; |
|
|
|
|
6
|
|
|
use SilverStripe\Forms\GridField\GridFieldDataColumns; |
7
|
|
|
use SilverStripe\ORM\DataExtension; |
8
|
|
|
use SilverStripe\Security\Member; |
9
|
|
|
use SilverStripe\VersionedAdmin\ArchiveAdmin; |
10
|
|
|
use SilverStripe\VersionedAdmin\ArchiveViewProvider; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Adds a archive view for Elemental blocks |
14
|
|
|
*/ |
15
|
|
|
class BlockArchiveExtension extends DataExtension implements ArchiveViewProvider |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @inheritDoc |
19
|
|
|
*/ |
20
|
|
|
public function getArchiveFieldClass() |
21
|
|
|
{ |
22
|
|
|
return BaseElement::class; |
|
|
|
|
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @inheritDoc |
27
|
|
|
*/ |
28
|
|
|
public function getArchiveField() |
29
|
|
|
{ |
30
|
|
|
$listField = ArchiveAdmin::createArchiveGridField('Blocks', BaseElement::class); |
31
|
|
|
|
32
|
|
|
$listColumns = $listField->getConfig()->getComponentByType(GridFieldDataColumns::class); |
33
|
|
|
$listColumns->setDisplayFields([ |
|
|
|
|
34
|
|
|
'Title' => BaseElement::singleton()->fieldLabel('Title'), |
35
|
|
|
'Type' => _t(ArchiveAdmin::class . '.COLUMN_TYPE', 'Type'), |
36
|
|
|
'LastEdited.Ago' => _t(ArchiveAdmin::class . '.COLUMN_DATEARCHIVED', 'Date Archived'), |
37
|
|
|
'Breadcrumbs' => _t(ArchiveAdmin::class . '.COLUMN_ORIGIN', 'Origin'), |
38
|
|
|
'AuthorID' => _t(ArchiveAdmin::class . '.COLUMN_ARCHIVEDBY', 'Archived By') |
39
|
|
|
]); |
40
|
|
|
$listColumns->setFieldFormatting([ |
|
|
|
|
41
|
|
|
'Breadcrumbs' => function ($val, $item) { |
42
|
|
|
$parent = $item->Page; |
43
|
|
|
|
44
|
|
|
return $parent ? $parent->Breadcrumbs() : null; |
45
|
|
|
}, |
46
|
|
|
'AuthorID' => function ($val, $item) { |
|
|
|
|
47
|
|
|
$member = Member::get_by_id($val); |
48
|
|
|
return $member ? $member->Name : null; |
|
|
|
|
49
|
|
|
}, |
50
|
|
|
]); |
51
|
|
|
|
52
|
|
|
return $listField; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @inheritDoc |
57
|
|
|
*/ |
58
|
|
|
public function isArchiveFieldEnabled() |
59
|
|
|
{ |
60
|
|
|
return true; |
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