1 | <?php |
||
3 | class CallToActionBlock extends Block |
||
4 | { |
||
5 | /** |
||
6 | * @return string |
||
7 | */ |
||
8 | 8 | public function singular_name() |
|
12 | |||
13 | /** |
||
14 | * @return string |
||
15 | */ |
||
16 | public function plural_name() |
||
20 | |||
21 | /** |
||
22 | * @var array |
||
23 | */ |
||
24 | private static $has_one = [ |
||
25 | 'BlockLink' => 'Link', |
||
26 | ]; |
||
27 | |||
28 | /** |
||
29 | * @return FieldList |
||
30 | */ |
||
31 | 1 | public function getCMSFields() |
|
32 | { |
||
33 | 1 | $this->beforeUpdateCMSFields(function ($fields) { |
|
34 | $fields->addFieldToTab( |
||
35 | 'Root.Main', |
||
36 | LinkField::create('BlockLinkID', 'Link') |
||
37 | ); |
||
38 | 1 | }); |
|
39 | |||
40 | 1 | $fields = parent::getCMSFields(); |
|
41 | |||
42 | $fields->removeByName([ |
||
43 | 'Title', |
||
44 | ]); |
||
45 | |||
46 | return $fields; |
||
47 | } |
||
48 | |||
49 | 1 | public function getTitle() |
|
55 | } |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: