1 | <?php |
||
2 | |||
3 | namespace DNADesign\ElementalUserForms\Model; |
||
4 | |||
5 | use SilverStripe\UserForms\Control\UserDefinedFormController; |
||
6 | use SilverStripe\UserForms\UserForm; |
||
7 | use SilverStripe\Control\Controller; |
||
8 | use DNADesign\Elemental\Models\BaseElement; |
||
9 | use DNADesign\ElementalUserForms\Control\ElementFormController; |
||
10 | |||
11 | class ElementForm extends BaseElement |
||
12 | { |
||
13 | use UserForm; |
||
14 | |||
15 | private static $table_name = 'ElementForm'; |
||
16 | |||
17 | private static $icon = 'dnadesign/silverstripe-elemental-userforms:images/form.svg'; |
||
18 | |||
19 | private static $controller_class = ElementFormController::class; |
||
20 | |||
21 | private static $singular_name = 'form'; |
||
0 ignored issues
–
show
|
|||
22 | |||
23 | private static $plural_name = 'forms'; |
||
0 ignored issues
–
show
|
|||
24 | |||
25 | /** |
||
26 | * @return UserForm |
||
27 | */ |
||
28 | public function ElementForm() |
||
29 | { |
||
30 | $controller = new UserDefinedFormController($this); |
||
31 | $current = Controller::curr(); |
||
32 | |||
33 | if ($current && $current->getAction() == 'finished') { |
||
34 | return $controller->renderWith(UserDefinedFormController::class .'_ReceivedFormSubmission'); |
||
35 | } |
||
36 | |||
37 | $form = $controller->Form(); |
||
38 | $form->setFormAction( |
||
39 | Controller::join_links( |
||
40 | $current->Link(), |
||
41 | 'element', |
||
42 | $this->owner->ID, |
||
43 | 'Form' |
||
44 | ) |
||
45 | ); |
||
46 | |||
47 | return $form; |
||
48 | } |
||
49 | |||
50 | public function Link($action = null) |
||
51 | { |
||
52 | $current = Controller::curr(); |
||
53 | |||
54 | if ($action === 'finished') { |
||
55 | return Controller::join_links( |
||
56 | $current->Link(), |
||
57 | 'finished' |
||
58 | ); |
||
59 | } |
||
60 | |||
61 | return parent::Link($action); |
||
62 | } |
||
63 | |||
64 | public function getType() |
||
65 | { |
||
66 | return _t(__CLASS__ . '.BlockType', 'Form'); |
||
67 | } |
||
68 | } |
||
69 |
This check marks private properties in classes that are never used. Those properties can be removed.