1 | <?php |
||
3 | class AccordionBlock extends Block |
||
4 | { |
||
5 | /** |
||
6 | * @return string |
||
7 | */ |
||
8 | 8 | public function singular_name() |
|
9 | { |
||
10 | 8 | return _t('AccordionBlock.SINGULARNAME', 'Accordion Block'); |
|
11 | } |
||
12 | |||
13 | /** |
||
14 | * @return string |
||
15 | */ |
||
16 | public function plural_name() |
||
20 | |||
21 | /** |
||
22 | * @var array |
||
23 | */ |
||
24 | private static $db = array( |
||
25 | 'Content' => 'HTMLText', |
||
26 | 'SortOrder' => 'Int', |
||
27 | ); |
||
28 | |||
29 | /** |
||
30 | * @var array |
||
31 | */ |
||
32 | private static $has_many = array( |
||
33 | 'Panels' => 'AccordionPanel', |
||
34 | ); |
||
35 | |||
36 | /** |
||
37 | * @return FieldList |
||
38 | */ |
||
39 | 1 | public function getCMSFields() |
|
40 | { |
||
41 | 1 | $fields = parent::getCMSFields(); |
|
42 | |||
43 | $fields->removeByName(array( |
||
44 | 'SortOrder', |
||
45 | 'Panels', |
||
46 | )); |
||
47 | |||
48 | $config = GridFieldConfig_RecordEditor::create(); |
||
49 | if (class_exists('GridFieldOrderableRows')) { |
||
50 | $config->addComponent(new GridFieldOrderableRows()); |
||
51 | } |
||
52 | $config->removeComponentsByType('GridFieldAddExistingAutocompleter'); |
||
53 | $config->removeComponentsByType('GridFieldDeleteAction'); |
||
54 | $config->addComponent(new GridFieldDeleteAction(false)); |
||
55 | |||
56 | if ($this->ID) { |
||
57 | $fields->addFieldsToTab('Root.Panels', array( |
||
58 | GridField::create('Panels', 'Accordion Panels', $this->Panels()->sort('Sort'), $config), |
||
|
|||
59 | )); |
||
60 | } |
||
61 | |||
62 | return $fields; |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * @return DataList |
||
67 | */ |
||
68 | 1 | public function getPanelList() |
|
75 | } |
||
76 | |||
108 | } |
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: