1 | <?php |
||
3 | class AccordionBlock extends Block |
||
4 | { |
||
5 | /** |
||
6 | * @return string |
||
7 | */ |
||
8 | 12 | public function singular_name() |
|
12 | |||
13 | /** |
||
14 | * @return string |
||
15 | */ |
||
16 | 1 | public function plural_name() |
|
17 | { |
||
18 | 1 | return _t('AccordionBlock.PLURALNAME', 'Accordion Blocks'); |
|
19 | } |
||
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 | 1 | $fields->removeByName(array( |
|
44 | 1 | 'SortOrder', |
|
45 | 1 | 'Panels', |
|
46 | 1 | )); |
|
47 | |||
48 | 1 | $config = GridFieldConfig_RecordEditor::create(); |
|
49 | 1 | if (class_exists('GridFieldOrderableRows')) { |
|
50 | 1 | $config->addComponent(new GridFieldOrderableRows()); |
|
51 | 1 | } |
|
52 | 1 | $config->removeComponentsByType('GridFieldAddExistingAutocompleter'); |
|
53 | 1 | $config->removeComponentsByType('GridFieldDeleteAction'); |
|
54 | 1 | $config->addComponent(new GridFieldDeleteAction(false)); |
|
55 | |||
56 | 1 | if ($this->ID) { |
|
57 | 1 | $fields->addFieldsToTab('Root.Panels', array( |
|
58 | 1 | GridField::create('Panels', 'Accordion Panels', $this->Panels()->sort('Sort'), $config), |
|
|
|||
59 | 1 | )); |
|
60 | 1 | } |
|
61 | |||
62 | 1 | return $fields; |
|
63 | } |
||
64 | |||
65 | /** |
||
66 | * @return DataList |
||
67 | */ |
||
68 | 1 | public function getPanelList() |
|
75 | } |
||
76 | |||
77 | class AccordionBlock_Controller extends Block_Controller |
||
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: