EditableFormStep::getCMSTitle()   A
last analyzed

Complexity

Conditions 3
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 7
nc 1
nop 0
dl 0
loc 10
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SilverStripe\UserForms\Model\EditableFormField;
4
5
use SilverStripe\Forms\LabelField;
6
use SilverStripe\UserForms\FormField\UserFormsStepField;
7
use SilverStripe\UserForms\Model\EditableFormField;
8
9
/**
10
 * A step in multi-page user form
11
 *
12
 * @package userforms
13
 */
14
class EditableFormStep extends EditableFormField
15
{
16
    private static $singular_name = 'Page Break';
0 ignored issues
show
introduced by
The private property $singular_name is not used, and could be removed.
Loading history...
17
18
    private static $plural_name = 'Page Breaks';
0 ignored issues
show
introduced by
The private property $plural_name is not used, and could be removed.
Loading history...
19
20
    /**
21
     * Disable selection of step class
22
     *
23
     * @config
24
     * @var bool
25
     */
26
    private static $hidden = true;
0 ignored issues
show
introduced by
The private property $hidden is not used, and could be removed.
Loading history...
27
28
    private static $table_name = 'EditableFormStep';
0 ignored issues
show
introduced by
The private property $table_name is not used, and could be removed.
Loading history...
29
30
    /**
31
     * @return FieldList
0 ignored issues
show
Bug introduced by
The type SilverStripe\UserForms\M...ableFormField\FieldList was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
32
     */
33
    public function getCMSFields()
34
    {
35
        $fields = parent::getCMSFields();
36
37
        $fields->removeByName(['MergeField', 'Default', 'Validation', 'RightTitle']);
38
39
        return $fields;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $fields returns the type SilverStripe\Forms\FieldList which is incompatible with the documented return type SilverStripe\UserForms\M...ableFormField\FieldList.
Loading history...
40
    }
41
42
    /**
43
     * @return FormField
0 ignored issues
show
Bug introduced by
The type SilverStripe\UserForms\M...ableFormField\FormField was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
44
     */
45
    public function getFormField()
46
    {
47
        $field = UserFormsStepField::create()
48
            ->setName($this->Name)
49
            ->setTitle($this->Title);
50
        $this->doUpdateFormField($field);
51
        return $field;
52
    }
53
54
    protected function updateFormField($field)
55
    {
56
        // if this field has an extra class
57
        if ($this->ExtraClass) {
0 ignored issues
show
Bug Best Practice introduced by
The property ExtraClass does not exist on SilverStripe\UserForms\M...mField\EditableFormStep. Since you implemented __get, consider adding a @property annotation.
Loading history...
58
            $field->addExtraClass($this->ExtraClass);
59
        }
60
    }
61
62
    /**
63
     * @return boolean
64
     */
65
    public function showInReports()
66
    {
67
        return false;
68
    }
69
70
    public function getInlineClassnameField($column, $fieldClasses)
71
    {
72
        return LabelField::create($column, $this->CMSTitle);
0 ignored issues
show
Bug Best Practice introduced by
The property CMSTitle does not exist on SilverStripe\UserForms\M...mField\EditableFormStep. Since you implemented __get, consider adding a @property annotation.
Loading history...
73
    }
74
75
    public function getCMSTitle()
76
    {
77
        $title = $this->getFieldNumber()
78
            ?: $this->Title
79
            ?: '';
80
81
        return _t(
82
            __CLASS__.'.STEP_TITLE',
83
            'Page {page}',
84
            ['page' => $title]
85
        );
86
    }
87
88
    /**
89
     * Get the JS expression for selecting the holder for this field
90
     *
91
     * @return string
92
     */
93
    public function getSelectorHolder()
94
    {
95
        return "$(\".step-button-wrapper[data-for='{$this->Name}']\")";
96
    }
97
}
98