1 | <?php |
||||
2 | |||||
3 | namespace Dynamic\Elements\Features\Model; |
||||
4 | |||||
5 | use Dynamic\BaseObject\Model\BaseElementObject; |
||||
6 | use Dynamic\Elements\Features\Elements\ElementFeatures; |
||||
7 | use SilverStripe\Forms\FieldList; |
||||
8 | |||||
9 | /** |
||||
10 | * Class PageSectionObject. |
||||
11 | * |
||||
12 | * @property int $Sort |
||||
13 | * @property int $ElementFeaturesID |
||||
14 | */ |
||||
15 | class FeatureObject extends BaseElementObject |
||||
16 | { |
||||
17 | /** |
||||
18 | * @var array |
||||
19 | */ |
||||
20 | private static $db = array( |
||||
0 ignored issues
–
show
introduced
by
![]() |
|||||
21 | 'Sort' => 'Int', |
||||
22 | ); |
||||
23 | |||||
24 | /** |
||||
25 | * @var array |
||||
26 | */ |
||||
27 | private static $has_one = array( |
||||
0 ignored issues
–
show
|
|||||
28 | 'ElementFeatures' => ElementFeatures::class, |
||||
29 | ); |
||||
30 | |||||
31 | /** |
||||
32 | * @var string |
||||
33 | */ |
||||
34 | private static $table_name = 'FeatureObject'; |
||||
0 ignored issues
–
show
|
|||||
35 | |||||
36 | /** |
||||
37 | * @var array |
||||
38 | */ |
||||
39 | private static $summary_fields = [ |
||||
0 ignored issues
–
show
|
|||||
40 | 'Summary', |
||||
41 | ]; |
||||
42 | |||||
43 | /** |
||||
44 | * @var string |
||||
45 | */ |
||||
46 | private static $default_sort = 'Sort'; |
||||
0 ignored issues
–
show
|
|||||
47 | |||||
48 | 1 | /** |
|||
49 | 1 | * @return FieldList |
|||
50 | 1 | * |
|||
51 | * @throws \Exception |
||||
52 | */ |
||||
53 | public function getCMSFields() |
||||
54 | 1 | { |
|||
55 | 1 | $this->beforeUpdateCMSFields(function ($fields) { |
|||
56 | 1 | $fields->removeByName(array( |
|||
57 | 'ElementFeaturesID', |
||||
58 | 1 | 'Sort', |
|||
59 | )); |
||||
60 | |||||
61 | $fields->dataFieldByName('Image') |
||||
62 | ->setFolderName('Uploads/Elements/Features'); |
||||
63 | }); |
||||
64 | 3 | ||||
65 | return parent::getCMSFields(); |
||||
66 | 3 | } |
|||
67 | |||||
68 | 3 | /** |
|||
69 | 3 | * @return null |
|||
70 | 3 | */ |
|||
71 | public function getPage() |
||||
72 | { |
||||
73 | $page = null; |
||||
74 | 3 | ||||
75 | if ($this->ElementFeatures()) { |
||||
0 ignored issues
–
show
The method
ElementFeatures() does not exist on Dynamic\Elements\Features\Model\FeatureObject . Since you implemented __call , consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
76 | if ($this->ElementFeatures()->hasMethod('getPage')) { |
||||
77 | $page = $this->ElementFeatures()->getPage(); |
||||
78 | } |
||||
79 | } |
||||
80 | |||||
81 | return $page; |
||||
82 | } |
||||
83 | |||||
84 | /** |
||||
85 | * @return mixed |
||||
86 | */ |
||||
87 | public function getSummary() |
||||
88 | { |
||||
89 | return $this->dbObject('Content')->Summary(20); |
||||
90 | } |
||||
91 | } |
||||
92 |