1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Dynamic\Elements\Section\Elements; |
4
|
|
|
|
5
|
|
|
use DNADesign\Elemental\Models\BaseElement; |
6
|
|
|
use DNADesign\Elemental\Models\ElementalArea; |
7
|
|
|
use DNADesign\ElementalList\Model\ElementList; |
|
|
|
|
8
|
|
|
use SilverStripe\ORM\FieldType\DBField; |
9
|
|
|
use SilverStripe\ORM\FieldType\DBHTMLText; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Class ElementSectionNavigation. |
13
|
|
|
*/ |
14
|
|
|
class ElementSectionNavigation extends BaseElement |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @var string |
18
|
|
|
*/ |
19
|
|
|
private static $icon = 'font-icon-menu'; |
|
|
|
|
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var string |
23
|
|
|
*/ |
24
|
|
|
private static $singular_name = 'Section Navigation Element'; |
|
|
|
|
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
private static $plural_name = 'Section Navigation Elements'; |
|
|
|
|
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
private static $table_name = 'ElementSectionNavigation'; |
|
|
|
|
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @return null|\SilverStripe\ORM\DataObject |
38
|
|
|
* @throws \SilverStripe\ORM\ValidationException |
39
|
|
|
*/ |
40
|
2 |
|
public function getPage() |
41
|
|
|
{ |
42
|
2 |
|
$area = $this->Parent(); |
43
|
|
|
|
44
|
2 |
|
if ($area instanceof ElementalArea && $area->exists()) { |
45
|
|
|
if ($area->getOwnerPage() instanceof ElementList && $area->getOwnerPage()->exists()) { |
46
|
|
|
return $area->getOwnerPage()->getPage(); |
47
|
|
|
} else { |
48
|
|
|
return $area->getOwnerPage(); |
49
|
|
|
} |
50
|
|
|
} |
51
|
2 |
|
return parent::getPage(); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @return bool|\SilverStripe\ORM\SS_List |
56
|
|
|
*/ |
57
|
1 |
|
public function getSectionNavigation() |
58
|
|
|
{ |
59
|
1 |
|
if ($page = $this->getPage()) { |
60
|
|
|
if ($page->Children()->Count() > 0) { |
61
|
|
|
return $page->Children(); |
62
|
|
|
} elseif ($page->Parent()) { |
63
|
|
|
return $page->Parent()->Children(); |
64
|
|
|
} else { |
65
|
|
|
return false; |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
69
|
1 |
|
return false; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return DBHTMLText |
74
|
|
|
*/ |
75
|
1 |
|
public function getSummary() |
76
|
|
|
{ |
77
|
1 |
|
if ($this->getPage()) { |
78
|
|
|
return DBField::create_field('HTMLText', 'Navigation for ' . $this->getPage()->Title)->Summary(20); |
79
|
|
|
} |
80
|
1 |
|
return DBField::create_field('HTMLText', '<p>Section Navigation</p>')->Summary(20); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @return array |
85
|
|
|
*/ |
86
|
|
|
protected function provideBlockSchema() |
87
|
|
|
{ |
88
|
|
|
$blockSchema = parent::provideBlockSchema(); |
89
|
|
|
$blockSchema['content'] = $this->getSummary(); |
90
|
|
|
return $blockSchema; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @return string |
95
|
|
|
*/ |
96
|
1 |
|
public function getType() |
97
|
|
|
{ |
98
|
1 |
|
return _t(__CLASS__.'.BlockType', 'Section Navigation'); |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|
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