44
55use eZ \Publish \API \Repository \ContentTypeService ;
66use eZ \Publish \API \Repository \Values \Content \Location ;
7+ use eZ \Publish \Core \MVC \ConfigResolverInterface ;
78use Netgen \Bundle \EzFormsBundle \Form \DataWrapper ;
89use Netgen \Bundle \EzFormsBundle \Form \Payload \InformationCollectionStruct ;
910use Netgen \Bundle \EzFormsBundle \Form \Type \InformationCollectionType ;
@@ -20,9 +21,9 @@ class FormBuilder
2021 protected $ formFactory ;
2122
2223 /**
23- * @var bool
24+ * @var ConfigResolverInterface
2425 */
25- protected $ useCsrf ;
26+ protected $ configResolver ;
2627
2728 /**
2829 * @var ContentTypeService
@@ -40,16 +41,16 @@ class FormBuilder
4041 * @param FormFactoryInterface $formFactory
4142 * @param ContentTypeService $contentTypeService
4243 * @param RouterInterface $router
43- * @param bool $useCsrf
44+ * @param ConfigResolverInterface $configResolver
4445 */
4546 public function __construct (
4647 FormFactoryInterface $ formFactory ,
4748 ContentTypeService $ contentTypeService ,
4849 RouterInterface $ router ,
49- $ useCsrf
50+ ConfigResolverInterface $ configResolver
5051 ) {
5152 $ this ->formFactory = $ formFactory ;
52- $ this ->useCsrf = $ useCsrf ;
53+ $ this ->configResolver = $ configResolver ;
5354 $ this ->contentTypeService = $ contentTypeService ;
5455 $ this ->router = $ router ;
5556 }
@@ -69,6 +70,7 @@ public function createFormForLocation(Location $location, $useAjax = false)
6970 $ contentType = $ this ->contentTypeService ->loadContentType ($ contentInfo ->contentTypeId );
7071
7172 $ data = new DataWrapper (new InformationCollectionStruct (), $ contentType , $ location );
73+ $ useCsrf = $ this ->configResolver ->getParameter ('information_collection.form.use_csrf ' , 'netgen ' );
7274
7375 $ formBuilder = $ this ->formFactory
7476 ->createNamedBuilder (
@@ -78,7 +80,7 @@ public function createFormForLocation(Location $location, $useAjax = false)
7880 InformationCollectionType::class,
7981 $ data ,
8082 array (
81- 'csrf_protection ' => $ this -> useCsrf ,
83+ 'csrf_protection ' => $ useCsrf ,
8284 )
8385 );
8486
0 commit comments