@@ -24,7 +24,7 @@ |
||
24 | 24 | ->children() |
25 | 25 | ->scalarNode('class') |
26 | 26 | ->validate() |
27 | - ->ifTrue(function ($class) { |
|
27 | + ->ifTrue(function($class) { |
|
28 | 28 | return !class_exists($class); |
29 | 29 | }) |
30 | 30 | ->thenInvalid("Class doesn't exist.") |
@@ -6,32 +6,32 @@ discard block |
||
6 | 6 | use Symfony\Component\Config\Definition\ConfigurationInterface; |
7 | 7 | |
8 | 8 | class Configuration implements ConfigurationInterface { |
9 | - public function getConfigTreeBuilder() { |
|
10 | - $treeBuilder = new TreeBuilder(); |
|
11 | - $rootNode = $treeBuilder->root('one_guard_dynamic_configuration'); |
|
9 | + public function getConfigTreeBuilder() { |
|
10 | + $treeBuilder = new TreeBuilder(); |
|
11 | + $rootNode = $treeBuilder->root('one_guard_dynamic_configuration'); |
|
12 | 12 | |
13 | - $rootNode |
|
14 | - ->addDefaultsIfNotSet() |
|
15 | - ->children() |
|
16 | - ->arrayNode('definitions') |
|
17 | - ->prototype('array') |
|
18 | - ->children() |
|
19 | - ->enumNode('type') |
|
20 | - ->values(['entity', 'string']) |
|
21 | - ->isRequired() |
|
22 | - ->end() |
|
23 | - ->arrayNode('options') |
|
24 | - ->children() |
|
25 | - ->scalarNode('class') |
|
26 | - ->validate() |
|
27 | - ->ifTrue(function ($class) { |
|
28 | - return !class_exists($class); |
|
29 | - }) |
|
30 | - ->thenInvalid("Class doesn't exist.") |
|
31 | - ->end() |
|
32 | - ->end() |
|
33 | - ->scalarNode('choice_label')->end() |
|
34 | - ->end() |
|
13 | + $rootNode |
|
14 | + ->addDefaultsIfNotSet() |
|
15 | + ->children() |
|
16 | + ->arrayNode('definitions') |
|
17 | + ->prototype('array') |
|
18 | + ->children() |
|
19 | + ->enumNode('type') |
|
20 | + ->values(['entity', 'string']) |
|
21 | + ->isRequired() |
|
22 | + ->end() |
|
23 | + ->arrayNode('options') |
|
24 | + ->children() |
|
25 | + ->scalarNode('class') |
|
26 | + ->validate() |
|
27 | + ->ifTrue(function ($class) { |
|
28 | + return !class_exists($class); |
|
29 | + }) |
|
30 | + ->thenInvalid("Class doesn't exist.") |
|
31 | + ->end() |
|
32 | + ->end() |
|
33 | + ->scalarNode('choice_label')->end() |
|
34 | + ->end() |
|
35 | 35 | // ->validate() |
36 | 36 | // ->ifTrue(function ($options) { |
37 | 37 | // if (!empty($options['class'])) { |
@@ -42,19 +42,19 @@ discard block |
||
42 | 42 | // }) |
43 | 43 | // ->thenInvalid("Property not accessible.") |
44 | 44 | // ->end() |
45 | - ->end() |
|
46 | - ->end() |
|
47 | - ->end() |
|
48 | - ->end() |
|
49 | - ->scalarNode('translation_domain') |
|
50 | - ->defaultValue('messages') |
|
51 | - ->cannotBeEmpty() |
|
52 | - ->end() |
|
53 | - ->scalarNode('translation_prefix') |
|
54 | - ->defaultValue('') |
|
55 | - ->end() |
|
56 | - ->end(); |
|
45 | + ->end() |
|
46 | + ->end() |
|
47 | + ->end() |
|
48 | + ->end() |
|
49 | + ->scalarNode('translation_domain') |
|
50 | + ->defaultValue('messages') |
|
51 | + ->cannotBeEmpty() |
|
52 | + ->end() |
|
53 | + ->scalarNode('translation_prefix') |
|
54 | + ->defaultValue('') |
|
55 | + ->end() |
|
56 | + ->end(); |
|
57 | 57 | |
58 | - return $treeBuilder; |
|
59 | - } |
|
58 | + return $treeBuilder; |
|
59 | + } |
|
60 | 60 | } |
@@ -21,10 +21,10 @@ |
||
21 | 21 | public function buildForm(FormBuilderInterface $builder, array $options) { |
22 | 22 | parent::buildForm($builder, $options); |
23 | 23 | $builder->addModelTransformer(new CallbackTransformer( |
24 | - function ($id) use ($options) { |
|
24 | + function($id) use ($options) { |
|
25 | 25 | return $id === null ? null : $this->doctrine->getRepository($options['class'])->find($id); |
26 | 26 | }, |
27 | - function ($entity) use ($options) { |
|
27 | + function($entity) use ($options) { |
|
28 | 28 | return $entity === null ? |
29 | 29 | null : $this->doctrine->getEntityManagerForClass($options['class'])->getUnitOfWork()->getSingleIdentifierValue($entity); |
30 | 30 | } |
@@ -8,26 +8,26 @@ |
||
8 | 8 | use Symfony\Component\Form\FormBuilderInterface; |
9 | 9 | |
10 | 10 | class EntityConfigurationValueType extends EntityType { |
11 | - /** |
|
12 | - * @var RegistryInterface |
|
13 | - */ |
|
14 | - private $doctrine; |
|
11 | + /** |
|
12 | + * @var RegistryInterface |
|
13 | + */ |
|
14 | + private $doctrine; |
|
15 | 15 | |
16 | - public function __construct(RegistryInterface $doctrine) { |
|
17 | - parent::__construct($doctrine); |
|
18 | - $this->doctrine = $doctrine; |
|
19 | - } |
|
16 | + public function __construct(RegistryInterface $doctrine) { |
|
17 | + parent::__construct($doctrine); |
|
18 | + $this->doctrine = $doctrine; |
|
19 | + } |
|
20 | 20 | |
21 | - public function buildForm(FormBuilderInterface $builder, array $options) { |
|
22 | - parent::buildForm($builder, $options); |
|
23 | - $builder->addModelTransformer(new CallbackTransformer( |
|
24 | - function ($id) use ($options) { |
|
25 | - return $id === null ? null : $this->doctrine->getRepository($options['class'])->find($id); |
|
26 | - }, |
|
27 | - function ($entity) use ($options) { |
|
28 | - return $entity === null ? |
|
29 | - null : $this->doctrine->getEntityManagerForClass($options['class'])->getUnitOfWork()->getSingleIdentifierValue($entity); |
|
30 | - } |
|
31 | - )); |
|
32 | - } |
|
21 | + public function buildForm(FormBuilderInterface $builder, array $options) { |
|
22 | + parent::buildForm($builder, $options); |
|
23 | + $builder->addModelTransformer(new CallbackTransformer( |
|
24 | + function ($id) use ($options) { |
|
25 | + return $id === null ? null : $this->doctrine->getRepository($options['class'])->find($id); |
|
26 | + }, |
|
27 | + function ($entity) use ($options) { |
|
28 | + return $entity === null ? |
|
29 | + null : $this->doctrine->getEntityManagerForClass($options['class'])->getUnitOfWork()->getSingleIdentifierValue($entity); |
|
30 | + } |
|
31 | + )); |
|
32 | + } |
|
33 | 33 | } |
@@ -48,13 +48,13 @@ |
||
48 | 48 | */ |
49 | 49 | public function assignAction(Request $request) { |
50 | 50 | $configurationValues = $this->entityManager->getRepository(ConfigurationValue::class)->findAll(); |
51 | - $existingValueKeys = array_map(function (ConfigurationValue $value) { |
|
51 | + $existingValueKeys = array_map(function(ConfigurationValue $value) { |
|
52 | 52 | return $value->getKey(); |
53 | 53 | }, $configurationValues); |
54 | 54 | $missingValueKeys = array_diff($this->registry->keys(), $existingValueKeys); |
55 | 55 | $configurationValues = array_merge( |
56 | 56 | $configurationValues, |
57 | - array_map(function (string $key) { |
|
57 | + array_map(function(string $key) { |
|
58 | 58 | $value = new ConfigurationValue(); |
59 | 59 | $value->setKey($key); |
60 | 60 | return $value; |
@@ -26,94 +26,94 @@ |
||
26 | 26 | * @Route(path="/configuration-value") |
27 | 27 | */ |
28 | 28 | class ConfigurationValueController extends Controller { |
29 | - /** |
|
30 | - * @var \Doctrine\ORM\EntityManagerInterface |
|
31 | - */ |
|
32 | - private $entityManager; |
|
29 | + /** |
|
30 | + * @var \Doctrine\ORM\EntityManagerInterface |
|
31 | + */ |
|
32 | + private $entityManager; |
|
33 | 33 | |
34 | - /** |
|
35 | - * @var DefinitionRegistry |
|
36 | - */ |
|
37 | - private $registry; |
|
34 | + /** |
|
35 | + * @var DefinitionRegistry |
|
36 | + */ |
|
37 | + private $registry; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @var ConfigurationResolverFactory |
|
41 | - */ |
|
42 | - private $factory; |
|
39 | + /** |
|
40 | + * @var ConfigurationResolverFactory |
|
41 | + */ |
|
42 | + private $factory; |
|
43 | 43 | |
44 | - public function __construct( |
|
45 | - RegistryInterface $doctrine, |
|
46 | - DefinitionRegistry $registry, |
|
47 | - ConfigurationResolverFactory $factory |
|
48 | - ) { |
|
49 | - $this->entityManager = $doctrine->getEntityManagerForClass(ConfigurationValue::class); |
|
50 | - $this->registry = $registry; |
|
51 | - $this->factory = $factory; |
|
52 | - } |
|
44 | + public function __construct( |
|
45 | + RegistryInterface $doctrine, |
|
46 | + DefinitionRegistry $registry, |
|
47 | + ConfigurationResolverFactory $factory |
|
48 | + ) { |
|
49 | + $this->entityManager = $doctrine->getEntityManagerForClass(ConfigurationValue::class); |
|
50 | + $this->registry = $registry; |
|
51 | + $this->factory = $factory; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @Route(path="/assign", name="configurationValue.assign") |
|
56 | - * @throws \Doctrine\ORM\OptimisticLockException |
|
57 | - * @throws \Doctrine\ORM\ORMException |
|
58 | - */ |
|
59 | - public function assignAction(Request $request) { |
|
60 | - $configurationValues = $this->entityManager->getRepository(ConfigurationValue::class)->findAll(); |
|
61 | - $existingValueKeys = array_map(function (ConfigurationValue $value) { |
|
62 | - return $value->getKey(); |
|
63 | - }, $configurationValues); |
|
64 | - $missingValueKeys = array_diff($this->registry->keys(), $existingValueKeys); |
|
65 | - $configurationValues = array_merge( |
|
66 | - $configurationValues, |
|
67 | - array_map(function (string $key) { |
|
68 | - $value = new ConfigurationValue(); |
|
69 | - $value->setKey($key); |
|
70 | - return $value; |
|
71 | - }, $missingValueKeys) |
|
72 | - ); |
|
54 | + /** |
|
55 | + * @Route(path="/assign", name="configurationValue.assign") |
|
56 | + * @throws \Doctrine\ORM\OptimisticLockException |
|
57 | + * @throws \Doctrine\ORM\ORMException |
|
58 | + */ |
|
59 | + public function assignAction(Request $request) { |
|
60 | + $configurationValues = $this->entityManager->getRepository(ConfigurationValue::class)->findAll(); |
|
61 | + $existingValueKeys = array_map(function (ConfigurationValue $value) { |
|
62 | + return $value->getKey(); |
|
63 | + }, $configurationValues); |
|
64 | + $missingValueKeys = array_diff($this->registry->keys(), $existingValueKeys); |
|
65 | + $configurationValues = array_merge( |
|
66 | + $configurationValues, |
|
67 | + array_map(function (string $key) { |
|
68 | + $value = new ConfigurationValue(); |
|
69 | + $value->setKey($key); |
|
70 | + return $value; |
|
71 | + }, $missingValueKeys) |
|
72 | + ); |
|
73 | 73 | |
74 | - $form = $this->createForm(ConfigurationValuesType::class, ['configurationValues' => $configurationValues]); |
|
75 | - $form->handleRequest($request); |
|
76 | - if ($form->isSubmitted() and $form->isValid()) { |
|
77 | - /* @var $configurationValue ConfigurationValue */ |
|
78 | - foreach ($form->get('configurationValues')->getData() as $configurationValue) { |
|
79 | - $isPersisted = \Doctrine\ORM\UnitOfWork::STATE_MANAGED === |
|
80 | - $this->entityManager->getUnitOfWork()->getEntityState($configurationValue); |
|
74 | + $form = $this->createForm(ConfigurationValuesType::class, ['configurationValues' => $configurationValues]); |
|
75 | + $form->handleRequest($request); |
|
76 | + if ($form->isSubmitted() and $form->isValid()) { |
|
77 | + /* @var $configurationValue ConfigurationValue */ |
|
78 | + foreach ($form->get('configurationValues')->getData() as $configurationValue) { |
|
79 | + $isPersisted = \Doctrine\ORM\UnitOfWork::STATE_MANAGED === |
|
80 | + $this->entityManager->getUnitOfWork()->getEntityState($configurationValue); |
|
81 | 81 | |
82 | - if ($configurationValue->getValue() === null and $isPersisted) { |
|
83 | - $this->entityManager->remove($configurationValue); |
|
84 | - } else if ($configurationValue->getValue() !== null and !$isPersisted) { |
|
85 | - $this->entityManager->persist($configurationValue); |
|
86 | - } |
|
87 | - } |
|
88 | - $this->entityManager->flush(); |
|
82 | + if ($configurationValue->getValue() === null and $isPersisted) { |
|
83 | + $this->entityManager->remove($configurationValue); |
|
84 | + } else if ($configurationValue->getValue() !== null and !$isPersisted) { |
|
85 | + $this->entityManager->persist($configurationValue); |
|
86 | + } |
|
87 | + } |
|
88 | + $this->entityManager->flush(); |
|
89 | 89 | |
90 | - return $this->redirectToRoute('configurationValue.view'); |
|
91 | - } |
|
90 | + return $this->redirectToRoute('configurationValue.view'); |
|
91 | + } |
|
92 | 92 | |
93 | - return $this->render('@OneGuardDynamicConfiguration/ConfigurationValue/assign.html.twig', ['form' => $form->createView()]); |
|
94 | - } |
|
93 | + return $this->render('@OneGuardDynamicConfiguration/ConfigurationValue/assign.html.twig', ['form' => $form->createView()]); |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * @Route(path="/view", name="configurationValue.view") |
|
98 | - */ |
|
99 | - public function viewAction() { |
|
100 | - /* @var $configurationValues ConfigurationValue[] */ |
|
101 | - $configurationValues = $this->entityManager->getRepository(ConfigurationValue::class)->findAll(); |
|
102 | - $labels = []; |
|
103 | - $propertyAccessor = new PropertyAccessor(); |
|
104 | - foreach ($configurationValues as $configurationValue) { |
|
105 | - $definition = $this->registry->get($configurationValue->getKey()); |
|
106 | - if ($definition instanceof EntityDefinition) { |
|
107 | - $object = $this->factory->create($definition->getKey())->resolve(); |
|
108 | - $labels[$definition->getKey()] = $propertyAccessor->getValue($object, $definition->getChoiceLabel()); |
|
109 | - } |
|
110 | - } |
|
96 | + /** |
|
97 | + * @Route(path="/view", name="configurationValue.view") |
|
98 | + */ |
|
99 | + public function viewAction() { |
|
100 | + /* @var $configurationValues ConfigurationValue[] */ |
|
101 | + $configurationValues = $this->entityManager->getRepository(ConfigurationValue::class)->findAll(); |
|
102 | + $labels = []; |
|
103 | + $propertyAccessor = new PropertyAccessor(); |
|
104 | + foreach ($configurationValues as $configurationValue) { |
|
105 | + $definition = $this->registry->get($configurationValue->getKey()); |
|
106 | + if ($definition instanceof EntityDefinition) { |
|
107 | + $object = $this->factory->create($definition->getKey())->resolve(); |
|
108 | + $labels[$definition->getKey()] = $propertyAccessor->getValue($object, $definition->getChoiceLabel()); |
|
109 | + } |
|
110 | + } |
|
111 | 111 | |
112 | - return $this->render('@OneGuardDynamicConfiguration/ConfigurationValue/view.html.twig', [ |
|
113 | - 'configurationValues' => $configurationValues, |
|
114 | - 'translationDomain' => $this->getParameter('one_guard.dynamic_configuration.translation_domain'), |
|
115 | - 'translationPrefix' => $this->getParameter('one_guard.dynamic_configuration.translation_prefix'), |
|
116 | - 'labels' => $labels |
|
117 | - ]); |
|
118 | - } |
|
112 | + return $this->render('@OneGuardDynamicConfiguration/ConfigurationValue/view.html.twig', [ |
|
113 | + 'configurationValues' => $configurationValues, |
|
114 | + 'translationDomain' => $this->getParameter('one_guard.dynamic_configuration.translation_domain'), |
|
115 | + 'translationPrefix' => $this->getParameter('one_guard.dynamic_configuration.translation_prefix'), |
|
116 | + 'labels' => $labels |
|
117 | + ]); |
|
118 | + } |
|
119 | 119 | } |
@@ -8,28 +8,28 @@ |
||
8 | 8 | use OneGuard\Bundle\DynamicConfigurationBundle\ProtectedReferencesChecker; |
9 | 9 | |
10 | 10 | class ProtectedReferencesDoctrineSubscriber implements EventSubscriber { |
11 | - /** |
|
12 | - * @var ProtectedReferencesChecker |
|
13 | - */ |
|
14 | - private $checker; |
|
11 | + /** |
|
12 | + * @var ProtectedReferencesChecker |
|
13 | + */ |
|
14 | + private $checker; |
|
15 | 15 | |
16 | - public function __construct(ProtectedReferencesChecker $checker) { |
|
17 | - $this->checker = $checker; |
|
18 | - } |
|
16 | + public function __construct(ProtectedReferencesChecker $checker) { |
|
17 | + $this->checker = $checker; |
|
18 | + } |
|
19 | 19 | |
20 | - public function getSubscribedEvents() { |
|
21 | - return [ |
|
22 | - 'preRemove' |
|
23 | - ]; |
|
24 | - } |
|
20 | + public function getSubscribedEvents() { |
|
21 | + return [ |
|
22 | + 'preRemove' |
|
23 | + ]; |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * @param LifecycleEventArgs $args |
|
28 | - * @throws ProtectedReferenceException |
|
29 | - * @throws \Doctrine\ORM\NoResultException |
|
30 | - * @throws \Doctrine\ORM\NonUniqueResultException |
|
31 | - */ |
|
32 | - public function preRemove(LifecycleEventArgs $args) { |
|
33 | - $this->checker->checkReferenceForProtection($args->getObject()); |
|
34 | - } |
|
26 | + /** |
|
27 | + * @param LifecycleEventArgs $args |
|
28 | + * @throws ProtectedReferenceException |
|
29 | + * @throws \Doctrine\ORM\NoResultException |
|
30 | + * @throws \Doctrine\ORM\NonUniqueResultException |
|
31 | + */ |
|
32 | + public function preRemove(LifecycleEventArgs $args) { |
|
33 | + $this->checker->checkReferenceForProtection($args->getObject()); |
|
34 | + } |
|
35 | 35 | } |
@@ -7,11 +7,11 @@ |
||
7 | 7 | use Symfony\Component\Form\FormBuilderInterface; |
8 | 8 | |
9 | 9 | class ConfigurationValuesType extends AbstractType { |
10 | - public function buildForm(FormBuilderInterface $builder, array $options) { |
|
11 | - $builder |
|
12 | - ->add('configurationValues', CollectionType::class, [ |
|
13 | - 'entry_type' => ConfigurationValueType::class, |
|
14 | - 'attr' => ['class' => 'panel panel-default panel-body'], |
|
15 | - ]); |
|
16 | - } |
|
10 | + public function buildForm(FormBuilderInterface $builder, array $options) { |
|
11 | + $builder |
|
12 | + ->add('configurationValues', CollectionType::class, [ |
|
13 | + 'entry_type' => ConfigurationValueType::class, |
|
14 | + 'attr' => ['class' => 'panel panel-default panel-body'], |
|
15 | + ]); |
|
16 | + } |
|
17 | 17 | } |
@@ -13,55 +13,55 @@ |
||
13 | 13 | use Symfony\Component\OptionsResolver\OptionsResolver; |
14 | 14 | |
15 | 15 | class ConfigurationValueType extends AbstractType { |
16 | - /** |
|
17 | - * @var DefinitionRegistry |
|
18 | - */ |
|
19 | - private $registry; |
|
16 | + /** |
|
17 | + * @var DefinitionRegistry |
|
18 | + */ |
|
19 | + private $registry; |
|
20 | 20 | |
21 | - private $translationDomain; |
|
22 | - private $translationPrefix; |
|
21 | + private $translationDomain; |
|
22 | + private $translationPrefix; |
|
23 | 23 | |
24 | - public function __construct( |
|
25 | - DefinitionRegistry $registry, |
|
26 | - string $translationDomain, |
|
27 | - string $translationPrefix |
|
28 | - ) { |
|
29 | - $this->registry = $registry; |
|
30 | - $this->translationDomain = $translationDomain; |
|
31 | - $this->translationPrefix = $translationPrefix; |
|
32 | - } |
|
24 | + public function __construct( |
|
25 | + DefinitionRegistry $registry, |
|
26 | + string $translationDomain, |
|
27 | + string $translationPrefix |
|
28 | + ) { |
|
29 | + $this->registry = $registry; |
|
30 | + $this->translationDomain = $translationDomain; |
|
31 | + $this->translationPrefix = $translationPrefix; |
|
32 | + } |
|
33 | 33 | |
34 | - public function buildForm(FormBuilderInterface $builder, array $options) { |
|
35 | - $builder |
|
36 | - ->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { |
|
37 | - /* @var $configurationValue ConfigurationValue */ |
|
38 | - $configurationValue = $event->getData(); |
|
39 | - $definition = $this->registry->get($configurationValue->getKey()); |
|
40 | - switch (get_class($definition)) { |
|
41 | - case EntityDefinition::class: |
|
42 | - /* @var $definition EntityDefinition */ |
|
43 | - $form = $event->getForm(); |
|
44 | - $form->add('value', EntityConfigurationValueType::class, [ |
|
45 | - 'class' => $definition->getClass(), |
|
46 | - 'choice_label' => $definition->getChoiceLabel(), |
|
47 | - 'label' => $this->translationPrefix . $configurationValue->getKey(), |
|
48 | - 'translation_domain' => $this->translationDomain, |
|
49 | - 'placeholder' => 'Please choose', |
|
50 | - 'empty_data' => null, |
|
51 | - 'required' => false |
|
52 | - ]); |
|
53 | - break; |
|
54 | - default: // assume StringDefinition |
|
55 | - $event->getForm()->add('value', TextType::class, [ |
|
56 | - 'label' => $this->translationPrefix . $configurationValue->getKey(), |
|
57 | - 'translation_domain' => $this->translationDomain, |
|
58 | - 'required' => false |
|
59 | - ]); |
|
60 | - } |
|
61 | - }); |
|
62 | - } |
|
34 | + public function buildForm(FormBuilderInterface $builder, array $options) { |
|
35 | + $builder |
|
36 | + ->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { |
|
37 | + /* @var $configurationValue ConfigurationValue */ |
|
38 | + $configurationValue = $event->getData(); |
|
39 | + $definition = $this->registry->get($configurationValue->getKey()); |
|
40 | + switch (get_class($definition)) { |
|
41 | + case EntityDefinition::class: |
|
42 | + /* @var $definition EntityDefinition */ |
|
43 | + $form = $event->getForm(); |
|
44 | + $form->add('value', EntityConfigurationValueType::class, [ |
|
45 | + 'class' => $definition->getClass(), |
|
46 | + 'choice_label' => $definition->getChoiceLabel(), |
|
47 | + 'label' => $this->translationPrefix . $configurationValue->getKey(), |
|
48 | + 'translation_domain' => $this->translationDomain, |
|
49 | + 'placeholder' => 'Please choose', |
|
50 | + 'empty_data' => null, |
|
51 | + 'required' => false |
|
52 | + ]); |
|
53 | + break; |
|
54 | + default: // assume StringDefinition |
|
55 | + $event->getForm()->add('value', TextType::class, [ |
|
56 | + 'label' => $this->translationPrefix . $configurationValue->getKey(), |
|
57 | + 'translation_domain' => $this->translationDomain, |
|
58 | + 'required' => false |
|
59 | + ]); |
|
60 | + } |
|
61 | + }); |
|
62 | + } |
|
63 | 63 | |
64 | - public function configureOptions(OptionsResolver $resolver) { |
|
65 | - $resolver->setDefault('data_class', ConfigurationValue::class); |
|
66 | - } |
|
64 | + public function configureOptions(OptionsResolver $resolver) { |
|
65 | + $resolver->setDefault('data_class', ConfigurationValue::class); |
|
66 | + } |
|
67 | 67 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | public function buildForm(FormBuilderInterface $builder, array $options) { |
35 | 35 | $builder |
36 | - ->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { |
|
36 | + ->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $event) { |
|
37 | 37 | /* @var $configurationValue ConfigurationValue */ |
38 | 38 | $configurationValue = $event->getData(); |
39 | 39 | $definition = $this->registry->get($configurationValue->getKey()); |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | $form->add('value', EntityConfigurationValueType::class, [ |
45 | 45 | 'class' => $definition->getClass(), |
46 | 46 | 'choice_label' => $definition->getChoiceLabel(), |
47 | - 'label' => $this->translationPrefix . $configurationValue->getKey(), |
|
47 | + 'label' => $this->translationPrefix.$configurationValue->getKey(), |
|
48 | 48 | 'translation_domain' => $this->translationDomain, |
49 | 49 | 'placeholder' => 'Please choose', |
50 | 50 | 'empty_data' => null, |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | break; |
54 | 54 | default: // assume StringDefinition |
55 | 55 | $event->getForm()->add('value', TextType::class, [ |
56 | - 'label' => $this->translationPrefix . $configurationValue->getKey(), |
|
56 | + 'label' => $this->translationPrefix.$configurationValue->getKey(), |
|
57 | 57 | 'translation_domain' => $this->translationDomain, |
58 | 58 | 'required' => false |
59 | 59 | ]); |
@@ -5,25 +5,25 @@ |
||
5 | 5 | use Symfony\Bridge\Doctrine\RegistryInterface; |
6 | 6 | |
7 | 7 | class ConfigurationResolverFactory { |
8 | - /** |
|
9 | - * @var RegistryInterface |
|
10 | - */ |
|
11 | - private $doctrine; |
|
8 | + /** |
|
9 | + * @var RegistryInterface |
|
10 | + */ |
|
11 | + private $doctrine; |
|
12 | 12 | |
13 | - /** |
|
14 | - * @var DefinitionRegistry |
|
15 | - */ |
|
16 | - private $registry; |
|
13 | + /** |
|
14 | + * @var DefinitionRegistry |
|
15 | + */ |
|
16 | + private $registry; |
|
17 | 17 | |
18 | - public function __construct(RegistryInterface $doctrine, DefinitionRegistry $registry) { |
|
19 | - $this->doctrine = $doctrine; |
|
20 | - $this->registry = $registry; |
|
21 | - } |
|
18 | + public function __construct(RegistryInterface $doctrine, DefinitionRegistry $registry) { |
|
19 | + $this->doctrine = $doctrine; |
|
20 | + $this->registry = $registry; |
|
21 | + } |
|
22 | 22 | |
23 | - public function create(string $key) { |
|
24 | - return new ConfigurationResolver( |
|
25 | - $this->doctrine, |
|
26 | - $this->registry->get($key) |
|
27 | - ); |
|
28 | - } |
|
23 | + public function create(string $key) { |
|
24 | + return new ConfigurationResolver( |
|
25 | + $this->doctrine, |
|
26 | + $this->registry->get($key) |
|
27 | + ); |
|
28 | + } |
|
29 | 29 | } |
@@ -5,15 +5,15 @@ |
||
5 | 5 | use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; |
6 | 6 | |
7 | 7 | class ProtectedReferenceException extends \Exception implements HttpExceptionInterface { |
8 | - public function __construct($message = "", $code = 0, \Throwable $previous = null) { |
|
9 | - parent::__construct($message, $code, $previous); |
|
10 | - } |
|
8 | + public function __construct($message = "", $code = 0, \Throwable $previous = null) { |
|
9 | + parent::__construct($message, $code, $previous); |
|
10 | + } |
|
11 | 11 | |
12 | - public function getStatusCode() { |
|
13 | - return 400; |
|
14 | - } |
|
12 | + public function getStatusCode() { |
|
13 | + return 400; |
|
14 | + } |
|
15 | 15 | |
16 | - public function getHeaders() { |
|
17 | - return []; |
|
18 | - } |
|
16 | + public function getHeaders() { |
|
17 | + return []; |
|
18 | + } |
|
19 | 19 | } |
@@ -3,32 +3,32 @@ |
||
3 | 3 | namespace OneGuard\Bundle\DynamicConfigurationBundle; |
4 | 4 | |
5 | 5 | class EntityDefinition extends Definition { |
6 | - private $class; |
|
7 | - private $choiceLabel; |
|
6 | + private $class; |
|
7 | + private $choiceLabel; |
|
8 | 8 | |
9 | - /** |
|
10 | - * EntityDefinition constructor. |
|
11 | - * @param $key |
|
12 | - * @param $class |
|
13 | - * @param $choiceLabel |
|
14 | - */ |
|
15 | - public function __construct($key, $class, $choiceLabel) { |
|
16 | - parent::__construct($key); |
|
17 | - $this->class = $class; |
|
18 | - $this->choiceLabel = $choiceLabel; |
|
19 | - } |
|
9 | + /** |
|
10 | + * EntityDefinition constructor. |
|
11 | + * @param $key |
|
12 | + * @param $class |
|
13 | + * @param $choiceLabel |
|
14 | + */ |
|
15 | + public function __construct($key, $class, $choiceLabel) { |
|
16 | + parent::__construct($key); |
|
17 | + $this->class = $class; |
|
18 | + $this->choiceLabel = $choiceLabel; |
|
19 | + } |
|
20 | 20 | |
21 | - /** |
|
22 | - * @return mixed |
|
23 | - */ |
|
24 | - public function getClass() { |
|
25 | - return $this->class; |
|
26 | - } |
|
21 | + /** |
|
22 | + * @return mixed |
|
23 | + */ |
|
24 | + public function getClass() { |
|
25 | + return $this->class; |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * @return mixed |
|
30 | - */ |
|
31 | - public function getChoiceLabel() { |
|
32 | - return $this->choiceLabel; |
|
33 | - } |
|
28 | + /** |
|
29 | + * @return mixed |
|
30 | + */ |
|
31 | + public function getChoiceLabel() { |
|
32 | + return $this->choiceLabel; |
|
33 | + } |
|
34 | 34 | } |