1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace LeKoala\Blocks; |
4
|
|
|
|
5
|
|
|
use SilverStripe\Core\ClassInfo; |
6
|
|
|
use SilverStripe\ORM\DataObject; |
7
|
|
|
use SilverStripe\View\ArrayData; |
8
|
|
|
use SilverStripe\View\ViewableData; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* This is the class you need to extend to create your own block |
12
|
|
|
* |
13
|
|
|
* Also see BlocksCreateTask to create to blocks for you |
14
|
|
|
*/ |
15
|
|
|
class BaseBlock extends ViewableData |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @var Block |
19
|
|
|
*/ |
20
|
|
|
protected $_block; |
21
|
|
|
|
22
|
|
|
public function __construct(Block $block) |
23
|
|
|
{ |
24
|
|
|
$this->_block = $block; |
25
|
|
|
|
26
|
|
|
// Allow calling base blocks methods (like Images, etc) |
27
|
|
|
$this->customise($block); |
28
|
|
|
|
29
|
|
|
// Allow calling any extra stuff on our block |
30
|
|
|
$data = $block->DataArray(); |
31
|
|
|
$settings = $block->SettingsArray(); |
32
|
|
|
$extra = $this->ExtraData(); |
33
|
|
|
$arrayData = new ArrayData(array_merge($data, $settings, $extra)); |
34
|
|
|
|
35
|
|
|
$this->setFailover($arrayData); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Allow direct queries from the template |
40
|
|
|
* |
41
|
|
|
* Use wisely... |
42
|
|
|
* |
43
|
|
|
* @param string $class |
44
|
|
|
* @return DataList |
|
|
|
|
45
|
|
|
*/ |
46
|
|
|
public function Query($class) |
47
|
|
|
{ |
48
|
|
|
// Allow unqualified classes |
49
|
|
|
if (!class_exists($class)) { |
50
|
|
|
$subclasses = ClassInfo::subclassesFor(DataObject::class); |
51
|
|
|
foreach ($subclasses as $lcName => $name) { |
52
|
|
|
$nameClass = Block::getClassWithoutNamespace($name); |
53
|
|
|
if ($class == $nameClass) { |
54
|
|
|
$class = $name; |
55
|
|
|
break; |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
return $class::get(); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function updateFields(BlockFieldList $fields) |
|
|
|
|
63
|
|
|
{ |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function updateClass(&$class) |
|
|
|
|
67
|
|
|
{ |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Extra data to feed to the template |
72
|
|
|
* @return array |
73
|
|
|
*/ |
74
|
|
|
public function ExtraData() |
75
|
|
|
{ |
76
|
|
|
return []; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @return DataList |
81
|
|
|
*/ |
82
|
|
|
public function Collection() |
83
|
|
|
{ |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @return DataList |
88
|
|
|
*/ |
89
|
|
|
public function SharedCollection() |
90
|
|
|
{ |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|
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