1 | <?php |
||
3 | class FormBlock extends Block |
||
4 | { |
||
5 | /** |
||
6 | * @var string |
||
7 | */ |
||
8 | private static $singular_name = 'Form Block'; |
||
9 | |||
10 | /** |
||
11 | * @var string |
||
12 | */ |
||
13 | private static $plural_name = 'Form Blocks'; |
||
14 | |||
15 | /** |
||
16 | * @var array |
||
17 | */ |
||
18 | private static $db = array( |
||
19 | 'Content' => 'HTMLText', |
||
20 | ); |
||
21 | |||
22 | /** |
||
23 | * @var array |
||
24 | */ |
||
25 | private static $has_one = array( |
||
26 | 'Form' => 'UserDefinedForm', |
||
27 | ); |
||
28 | |||
29 | /** |
||
30 | * @return FieldList |
||
31 | */ |
||
32 | 1 | public function getCMSFields() |
|
33 | { |
||
34 | 1 | $fields = singleton('Block')->getCMSFields(); |
|
35 | |||
36 | if (class_exists('UserDefinedForm')) { |
||
37 | $fields->addFieldToTab('Root.Main', DropdownField::create( |
||
38 | 'FormID', |
||
39 | 'Form', |
||
40 | UserDefinedForm::get()->map() |
||
41 | )->setEmptyString('') |
||
42 | ->setDescription('select an existing User Defined Form to display') |
||
43 | ); |
||
44 | } |
||
45 | |||
46 | $fields->addFieldToTab('Root.Main', HtmlEditorField::create('Content')); |
||
47 | |||
48 | return $fields; |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * @return Forms|HTMLText |
||
53 | */ |
||
54 | public function BlockForm() |
||
66 | |||
67 | /** |
||
68 | * @param null $member |
||
69 | * @return bool |
||
70 | */ |
||
71 | public function canCreate($member = null) |
||
78 | |||
79 | /** |
||
80 | * @param null $member |
||
81 | * @return bool |
||
82 | */ |
||
83 | public function canView($member = null) |
||
90 | } |
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: