12
12
namespace Symfony \Bundle \FrameworkBundle \DependencyInjection ;
13
13
14
14
use Doctrine \Common \Annotations \Annotation ;
15
+ use Symfony \Bundle \FullStack ;
16
+ use Symfony \Component \Asset \Package ;
15
17
use Symfony \Component \Config \Definition \Builder \ArrayNodeDefinition ;
16
18
use Symfony \Component \Config \Definition \Builder \TreeBuilder ;
17
19
use Symfony \Component \Config \Definition \ConfigurationInterface ;
20
+ use Symfony \Component \Form \Form ;
21
+ use Symfony \Component \Security \Csrf \CsrfToken ;
22
+ use Symfony \Component \Serializer \Serializer ;
23
+ use Symfony \Component \Translation \Translator ;
24
+ use Symfony \Component \Validator \Validation ;
18
25
19
26
/**
20
27
* FrameworkExtension configuration structure.
@@ -127,7 +134,7 @@ private function addCsrfSection(ArrayNodeDefinition $rootNode)
127
134
$ rootNode
128
135
->children ()
129
136
->arrayNode ('csrf_protection ' )
130
- ->canBeEnabled ()
137
+ ->{! class_exists (FullStack::class) && class_exists (CsrfToken::class) ? ' canBeDisabled ' : ' canBeEnabled ' } ()
131
138
->end ()
132
139
->end ()
133
140
;
@@ -139,7 +146,7 @@ private function addFormSection(ArrayNodeDefinition $rootNode)
139
146
->children ()
140
147
->arrayNode ('form ' )
141
148
->info ('form configuration ' )
142
- ->canBeEnabled ()
149
+ ->{! class_exists (FullStack::class) && class_exists (Form::class) ? ' canBeDisabled ' : ' canBeEnabled ' } ()
143
150
->children ()
144
151
->arrayNode ('csrf_protection ' )
145
152
->treatFalseLike (array ('enabled ' => false ))
@@ -506,7 +513,7 @@ private function addAssetsSection(ArrayNodeDefinition $rootNode)
506
513
->children ()
507
514
->arrayNode ('assets ' )
508
515
->info ('assets configuration ' )
509
- ->canBeEnabled ()
516
+ ->{! class_exists (FullStack::class) && class_exists (Package::class) ? ' canBeDisabled ' : ' canBeEnabled ' } ()
510
517
->fixXmlConfig ('base_url ' )
511
518
->children ()
512
519
->scalarNode ('version_strategy ' )->defaultNull ()->end ()
@@ -573,7 +580,7 @@ private function addTranslatorSection(ArrayNodeDefinition $rootNode)
573
580
->children ()
574
581
->arrayNode ('translator ' )
575
582
->info ('translator configuration ' )
576
- ->canBeEnabled ()
583
+ ->{! class_exists (FullStack::class) && class_exists (Translator::class) ? ' canBeDisabled ' : ' canBeEnabled ' } ()
577
584
->fixXmlConfig ('fallback ' )
578
585
->fixXmlConfig ('path ' )
579
586
->children ()
@@ -598,7 +605,7 @@ private function addValidationSection(ArrayNodeDefinition $rootNode)
598
605
->children ()
599
606
->arrayNode ('validation ' )
600
607
->info ('validation configuration ' )
601
- ->canBeEnabled ()
608
+ ->{! class_exists (FullStack::class) && class_exists (Validation::class) ? ' canBeDisabled ' : ' canBeEnabled ' } ()
602
609
->children ()
603
610
->scalarNode ('cache ' )->end ()
604
611
->booleanNode ('enable_annotations ' )->{class_exists (Annotation::class) ? 'defaultTrue ' : 'defaultFalse ' }()->end ()
@@ -642,7 +649,7 @@ private function addSerializerSection(ArrayNodeDefinition $rootNode)
642
649
->children ()
643
650
->arrayNode ('serializer ' )
644
651
->info ('serializer configuration ' )
645
- ->canBeEnabled ()
652
+ ->{! class_exists (FullStack::class) && class_exists (Serializer::class) ? ' canBeDisabled ' : ' canBeEnabled ' } ()
646
653
->children ()
647
654
->booleanNode ('enable_annotations ' )->{class_exists (Annotation::class) ? 'defaultTrue ' : 'defaultFalse ' }()->end ()
648
655
->scalarNode ('cache ' )->end ()
0 commit comments