Passed
Push — master ( 0dfbbd...579ce9 )
by Gabor
06:47
created

ApplicationCreateForm   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 104
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 66
dl 0
loc 104
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
B init() 0 87 1
A initAdapter() 0 3 1
1
<?php
2
/**
3
 * WebHemi.
4
 *
5
 * PHP version 7.2
6
 *
7
 * @copyright 2012 - 2019 Gixx-web (http://www.gixx-web.com)
8
 * @license   https://opensource.org/licenses/MIT The MIT License (MIT)
9
 *
10
 * @link http://www.gixx-web.com
11
 */
12
declare(strict_types = 1);
13
14
namespace WebHemi\Form\Preset;
15
16
use WebHemi\CSRF\ServiceInterface as CSRFInterface;
17
use WebHemi\Form\Element\Html\HtmlElement;
18
use WebHemi\Validator;
19
20
/**
21
 * Class ApplicationEditForm
22
 *
23
 * @codeCoverageIgnore - only composes an object.
24
 */
25
class ApplicationCreateForm extends AbstractPreset
26
{
27
    /**
28
     * Initialize the adapter
29
     */
30
    protected function initAdapter()
31
    {
32
        $this->formAdapter->initialize('application', '', 'POST');
33
    }
34
35
    /**
36
     * Initialize and add elements to the form.
37
     *
38
     * @return void
39
     *
40
     * @codeCoverageIgnore - only composes an object.
41
     */
42
    protected function init() : void
43
    {
44
        $this->initAdapter();
45
46
        $csrf = $this->createElement(
47
            HtmlElement::class,
48
            HtmlElement::HTML_ELEMENT_HIDDEN,
49
            CSRFInterface::SESSION_KEY,
50
            ''
51
        );
52
53
        $name = $this->createElement(
54
            HtmlElement::class,
55
            HtmlElement::HTML_ELEMENT_INPUT_TEXT,
56
            'name',
57
            'Application name'
58
        );
59
        $name->addValidator($this->validatorCollection->getValidator(Validator\NotEmptyValidator::class));
60
61
        $title = $this->createElement(
62
            HtmlElement::class,
63
            HtmlElement::HTML_ELEMENT_INPUT_TEXT,
64
            'title',
65
            'Display name (title)'
66
        );
67
        $title->addValidator($this->validatorCollection->getValidator(Validator\NotEmptyValidator::class));
68
69
        $introduction = $this->createElement(
70
            HtmlElement::class,
71
            HtmlElement::HTML_ELEMENT_TEXTAREA,
72
            'introduction',
73
            'Introduction'
74
        );
75
76
        $subject = $this->createElement(
77
            HtmlElement::class,
78
            HtmlElement::HTML_ELEMENT_TEXTAREA,
79
            'subject',
80
            'Subject'
81
        );
82
83
        $description = $this->createElement(
84
            HtmlElement::class,
85
            HtmlElement::HTML_ELEMENT_TEXTAREA,
86
            'description',
87
            'Description'
88
        );
89
90
        $keywords = $this->createElement(
91
            HtmlElement::class,
92
            HtmlElement::HTML_ELEMENT_INPUT_TEXT,
93
            'keywords',
94
            'Keywords'
95
        );
96
97
        $copyright = $this->createElement(
98
            HtmlElement::class,
99
            HtmlElement::HTML_ELEMENT_INPUT_TEXT,
100
            'copyright',
101
            'Copyright'
102
        );
103
104
        $cancel = $this->createElement(
105
            HtmlElement::class,
106
            HtmlElement::HTML_ELEMENT_BUTTON,
107
            'cancel',
108
            'Cancel'
109
        );
110
111
        $submit = $this->createElement(
112
            HtmlElement::class,
113
            HtmlElement::HTML_ELEMENT_SUBMIT,
114
            'submit',
115
            'Save'
116
        );
117
118
        $this->formAdapter
119
            ->addElement($csrf)
120
            ->addElement($name)
121
            ->addElement($title)
122
            ->addElement($introduction)
123
            ->addElement($subject)
124
            ->addElement($description)
125
            ->addElement($keywords)
126
            ->addElement($copyright)
127
            ->addElement($cancel)
128
            ->addElement($submit);
129
    }
130
}
131