4
4
5
5
use eZ \Publish \API \Repository \ContentTypeService ;
6
6
use eZ \Publish \API \Repository \Values \Content \Location ;
7
+ use eZ \Publish \Core \MVC \ConfigResolverInterface ;
7
8
use Netgen \Bundle \EzFormsBundle \Form \DataWrapper ;
8
9
use Netgen \Bundle \EzFormsBundle \Form \Payload \InformationCollectionStruct ;
9
10
use Netgen \Bundle \EzFormsBundle \Form \Type \InformationCollectionType ;
@@ -20,9 +21,9 @@ class FormBuilder
20
21
protected $ formFactory ;
21
22
22
23
/**
23
- * @var bool
24
+ * @var ConfigResolverInterface
24
25
*/
25
- protected $ useCsrf ;
26
+ protected $ configResolver ;
26
27
27
28
/**
28
29
* @var ContentTypeService
@@ -40,16 +41,16 @@ class FormBuilder
40
41
* @param FormFactoryInterface $formFactory
41
42
* @param ContentTypeService $contentTypeService
42
43
* @param RouterInterface $router
43
- * @param bool $useCsrf
44
+ * @param ConfigResolverInterface $configResolver
44
45
*/
45
46
public function __construct (
46
47
FormFactoryInterface $ formFactory ,
47
48
ContentTypeService $ contentTypeService ,
48
49
RouterInterface $ router ,
49
- $ useCsrf
50
+ ConfigResolverInterface $ configResolver
50
51
) {
51
52
$ this ->formFactory = $ formFactory ;
52
- $ this ->useCsrf = $ useCsrf ;
53
+ $ this ->configResolver = $ configResolver ;
53
54
$ this ->contentTypeService = $ contentTypeService ;
54
55
$ this ->router = $ router ;
55
56
}
@@ -69,6 +70,7 @@ public function createFormForLocation(Location $location, $useAjax = false)
69
70
$ contentType = $ this ->contentTypeService ->loadContentType ($ contentInfo ->contentTypeId );
70
71
71
72
$ data = new DataWrapper (new InformationCollectionStruct (), $ contentType , $ location );
73
+ $ useCsrf = $ this ->configResolver ->getParameter ('information_collection.form.use_csrf ' , 'netgen ' );
72
74
73
75
$ formBuilder = $ this ->formFactory
74
76
->createNamedBuilder (
@@ -78,7 +80,7 @@ public function createFormForLocation(Location $location, $useAjax = false)
78
80
InformationCollectionType::class,
79
81
$ data ,
80
82
array (
81
- 'csrf_protection ' => $ this -> useCsrf ,
83
+ 'csrf_protection ' => $ useCsrf ,
82
84
)
83
85
);
84
86
0 commit comments