Completed
Push — master ( 663a06...123975 )
by Robbie
02:38
created

ElementForm   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 46
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A ElementForm() 0 19 3
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
    /**
16
     * @var string
17
     */
18
    private static $table_name = 'ElementForm';
0 ignored issues
show
Unused Code introduced by
The property $table_name is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
19
20
    /**
21
     * @var string
22
     */
23
    private static $title = 'Form';
0 ignored issues
show
Unused Code introduced by
The property $title is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
24
25
    /**
26
     * @var string
27
     */
28
    private static $icon = 'dnadesign/silverstripe-elemental-userforms:images/form.svg';
0 ignored issues
show
Unused Code introduced by
The property $icon is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
29
30
    /**
31
     * @var string
32
     */
33
    private static $controller_class = ElementFormController::class;
0 ignored issues
show
Unused Code introduced by
The property $controller_class is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
34
35
    /**
36
     * @return UserForm
37
     */
38
    public function ElementForm()
0 ignored issues
show
Coding Style Best Practice introduced by
Please use __construct() instead of a PHP4-style constructor that is named after the class.
Loading history...
39
    {
40
        $controller = new UserDefinedFormController($this);
41
        $current = Controller::curr();
42
43
        if ($current && $current->getAction() == 'finished') {
44
            return $controller->renderWith('ReceivedFormSubmission');
45
        }
46
47
        $form = $controller->Form();
48
        $form->setFormAction(
49
            Controller::join_links(
50
                $current->Link(),
51
                'element',
52
                $this->owner->ID
0 ignored issues
show
Bug Best Practice introduced by
The property owner does not exist on DNADesign\ElementalUserForms\Model\ElementForm. Since you implemented __get, consider adding a @property annotation.
Loading history...
53
            )
54
        );
55
56
        return $form;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $form returns the type SilverStripe\Forms\Form which is incompatible with the documented return type SilverStripe\UserForms\UserForm.
Loading history...
57
    }
58
}
59