1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* WellCommerce Open-Source E-Commerce Platform |
4
|
|
|
* |
5
|
|
|
* This file is part of the WellCommerce package. |
6
|
|
|
* |
7
|
|
|
* (c) Adam Piotrowski <[email protected]> |
8
|
|
|
* |
9
|
|
|
* For the full copyright and license information, |
10
|
|
|
* please view the LICENSE file that was distributed with this source code. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace WellCommerce\Bundle\ReviewBundle\Form\Admin; |
14
|
|
|
|
15
|
|
|
use WellCommerce\Bundle\CoreBundle\Form\AbstractFormBuilder; |
16
|
|
|
use WellCommerce\Component\Form\Elements\FormInterface; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Class ReviewFormBuilder |
20
|
|
|
* |
21
|
|
|
* @author Adam Piotrowski <[email protected]> |
22
|
|
|
*/ |
23
|
|
|
class ReviewFormBuilder extends AbstractFormBuilder |
24
|
|
|
{ |
25
|
|
|
public function getAlias(): string |
26
|
|
|
{ |
27
|
|
|
return 'admin.review'; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function buildForm(FormInterface $form) |
31
|
|
|
{ |
32
|
|
|
$mainData = $form->addChild($this->getElement('nested_fieldset', [ |
33
|
|
|
'name' => 'required_data', |
34
|
|
|
'label' => 'common.fieldset.general', |
35
|
|
|
])); |
36
|
|
|
|
37
|
|
|
$mainData->addChild($this->getElement('checkbox', [ |
38
|
|
|
'name' => 'enabled', |
39
|
|
|
'label' => 'common.label.enabled', |
40
|
|
|
])); |
41
|
|
|
|
42
|
|
|
$mainData->addChild($this->getElement('text_field', [ |
43
|
|
|
'name' => 'nick', |
44
|
|
|
'label' => 'review.label.nick', |
45
|
|
|
])); |
46
|
|
|
|
47
|
|
|
$mainData->addChild($this->getElement('select', [ |
48
|
|
|
'name' => 'rating', |
49
|
|
|
'label' => 'review.label.rating', |
50
|
|
|
'options' => $this->getRatingOptions(), |
51
|
|
|
])); |
52
|
|
|
|
53
|
|
|
$mainData->addChild($this->getElement('text_area', [ |
54
|
|
|
'name' => 'review', |
55
|
|
|
'label' => 'review.label.review', |
56
|
|
|
'rows' => 5, |
57
|
|
|
'cols' => 10, |
58
|
|
|
])); |
59
|
|
|
|
60
|
|
|
$form->addFilter($this->getFilter('no_code')); |
61
|
|
|
$form->addFilter($this->getFilter('trim')); |
62
|
|
|
$form->addFilter($this->getFilter('secure')); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
private function getRatingOptions(): array |
66
|
|
|
{ |
67
|
|
|
$rating = []; |
68
|
|
|
foreach (range(1, 5, 1) as $range) { |
69
|
|
|
$rating[$range] = $range; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
return $rating; |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|