From c76171c4e0be49be7702c80e58100474c7fe8a0a Mon Sep 17 00:00:00 2001 From: BadPixxel Date: Sun, 12 Mar 2017 23:32:11 +0100 Subject: [PATCH 1/4] Added RouteParameters to MenuNodeAdmin --- src/Admin/Menu/MenuNodeAdmin.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Admin/Menu/MenuNodeAdmin.php b/src/Admin/Menu/MenuNodeAdmin.php index d9064da..a1dbb25 100644 --- a/src/Admin/Menu/MenuNodeAdmin.php +++ b/src/Admin/Menu/MenuNodeAdmin.php @@ -21,6 +21,7 @@ use Sonata\DoctrinePHPCRAdminBundle\Form\Type\ChoiceFieldMaskType; use Knp\Menu\ItemInterface as MenuItemInterface; use Doctrine\Common\Util\ClassUtils; +use Burgov\Bundle\KeyValueFormBundle\Form\Type\KeyValueType; class MenuNodeAdmin extends AbstractMenuNodeAdmin { @@ -69,7 +70,7 @@ protected function configureFormFields(FormMapper $formMapper) 'content' => 'content', ), 'map' => array( - 'route' => array('link'), + 'route' => array('link','routeParameters'), 'uri' => array('link'), 'content' => array('content', TreeSelectType::class), ), @@ -77,6 +78,16 @@ protected function configureFormFields(FormMapper $formMapper) 'required' => false, )) ->add('link', TextType::class, array('required' => false, 'mapped' => false)) + ->add('routeParameters', KeyValueType::class, array( + 'value_type' => TextType::class, + 'required' => false, + 'entry_options' => array( + 'value_type' => TextType::class, + 'label' => false, + 'attr' => array('style' => 'clear:both'), + ), + "label" => "form.label_options" + )) ->add( 'content', TreeSelectType::class, From 87fd8c85c75232f834c5259a9b3af2baf68fb9fd Mon Sep 17 00:00:00 2001 From: nanard33 Date: Tue, 25 Apr 2017 23:30:22 +0200 Subject: [PATCH 2/4] Sauvegarde --- src/Admin/Menu/AbstractMenuNodeAdmin.php | 10 ++++++++ src/Admin/Menu/MenuNodeAdmin.php | 31 +++++++++++++++--------- src/Resources/config/menu.xml | 4 +++ 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/src/Admin/Menu/AbstractMenuNodeAdmin.php b/src/Admin/Menu/AbstractMenuNodeAdmin.php index c1a03b2..ecec13a 100644 --- a/src/Admin/Menu/AbstractMenuNodeAdmin.php +++ b/src/Admin/Menu/AbstractMenuNodeAdmin.php @@ -33,6 +33,11 @@ abstract class AbstractMenuNodeAdmin extends AbstractAdmin */ protected $menuRoot; + /** + * @var bool + */ + protected $advanced; + /** * @var string */ @@ -92,6 +97,11 @@ public function setContentTreeBlock($contentTreeBlock) $this->contentTreeBlock = $contentTreeBlock; } + public function setAdvanced($advanced) + { + $this->advanced = $advanced; + } + public function toString($object) { if ($object instanceof MenuNodeBase && $object->getLabel()) { diff --git a/src/Admin/Menu/MenuNodeAdmin.php b/src/Admin/Menu/MenuNodeAdmin.php index a1dbb25..f0ecb13 100644 --- a/src/Admin/Menu/MenuNodeAdmin.php +++ b/src/Admin/Menu/MenuNodeAdmin.php @@ -53,7 +53,7 @@ protected function configureFormFields(FormMapper $formMapper) ->end() ->end() ; - + $this->addTransformerToField($formMapper->getFormBuilder(), 'parentDocument'); parent::configureFormFields($formMapper); @@ -70,7 +70,7 @@ protected function configureFormFields(FormMapper $formMapper) 'content' => 'content', ), 'map' => array( - 'route' => array('link','routeParameters'), + 'route' => array('link', 'routeParameters'), 'uri' => array('link'), 'content' => array('content', TreeSelectType::class), ), @@ -78,16 +78,25 @@ protected function configureFormFields(FormMapper $formMapper) 'required' => false, )) ->add('link', TextType::class, array('required' => false, 'mapped' => false)) - ->add('routeParameters', KeyValueType::class, array( + ; + + if ($this->advanced) + { + $formMapper + ->add('routeParameters', KeyValueType::class, array( + 'value_type' => TextType::class, + 'required' => false, + 'entry_options' => array( 'value_type' => TextType::class, - 'required' => false, - 'entry_options' => array( - 'value_type' => TextType::class, - 'label' => false, - 'attr' => array('style' => 'clear:both'), - ), - "label" => "form.label_options" - )) + 'label' => false, + 'attr' => array('style' => 'clear:both'), + ), + 'label' => 'form.label_options' + )) + ; + } + + $formMapper ->add( 'content', TreeSelectType::class, diff --git a/src/Resources/config/menu.xml b/src/Resources/config/menu.xml index 67615b8..773a82f 100644 --- a/src/Resources/config/menu.xml +++ b/src/Resources/config/menu.xml @@ -68,6 +68,10 @@ %cmf_sonata_phpcr_admin_integration.menu.recursive_breadcrumbs% + + + %cmf_sonata_phpcr_admin_integration.menu.extension.menu_options.advanced% + Date: Tue, 25 Apr 2017 23:37:56 +0200 Subject: [PATCH 3/4] Update MenuNodeAdmin.php --- src/Admin/Menu/MenuNodeAdmin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Admin/Menu/MenuNodeAdmin.php b/src/Admin/Menu/MenuNodeAdmin.php index f0ecb13..55bc774 100644 --- a/src/Admin/Menu/MenuNodeAdmin.php +++ b/src/Admin/Menu/MenuNodeAdmin.php @@ -53,7 +53,7 @@ protected function configureFormFields(FormMapper $formMapper) ->end() ->end() ; - + $this->addTransformerToField($formMapper->getFormBuilder(), 'parentDocument'); parent::configureFormFields($formMapper); From 1c68da5b5c370402bcb03b7b95f13a36ec330bbc Mon Sep 17 00:00:00 2001 From: BadPixxel Date: Mon, 1 May 2017 17:52:55 +0200 Subject: [PATCH 4/4] Admin Menu Node Routes Parameters. Now use dedicated parameter to detect BurgovKeyValueForm Bundle. --- src/Admin/Menu/AbstractMenuNodeAdmin.php | 6 +++--- src/Admin/Menu/MenuNodeAdmin.php | 2 +- src/DependencyInjection/Factory/MenuAdminFactory.php | 9 +++++++++ src/Resources/config/menu.xml | 4 ++-- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/Admin/Menu/AbstractMenuNodeAdmin.php b/src/Admin/Menu/AbstractMenuNodeAdmin.php index ecec13a..3d0fdec 100644 --- a/src/Admin/Menu/AbstractMenuNodeAdmin.php +++ b/src/Admin/Menu/AbstractMenuNodeAdmin.php @@ -36,7 +36,7 @@ abstract class AbstractMenuNodeAdmin extends AbstractAdmin /** * @var bool */ - protected $advanced; + protected $useBurgovKeyValueForm; /** * @var string @@ -97,9 +97,9 @@ public function setContentTreeBlock($contentTreeBlock) $this->contentTreeBlock = $contentTreeBlock; } - public function setAdvanced($advanced) + public function setUseBurgovKeyValueForm($useBurgovKeyValueForm) { - $this->advanced = $advanced; + $this->useBurgovKeyValueForm = $useBurgovKeyValueForm; } public function toString($object) diff --git a/src/Admin/Menu/MenuNodeAdmin.php b/src/Admin/Menu/MenuNodeAdmin.php index 55bc774..6604c15 100644 --- a/src/Admin/Menu/MenuNodeAdmin.php +++ b/src/Admin/Menu/MenuNodeAdmin.php @@ -80,7 +80,7 @@ protected function configureFormFields(FormMapper $formMapper) ->add('link', TextType::class, array('required' => false, 'mapped' => false)) ; - if ($this->advanced) + if ($this->useBurgovKeyValueForm) { $formMapper ->add('routeParameters', KeyValueType::class, array( diff --git a/src/DependencyInjection/Factory/MenuAdminFactory.php b/src/DependencyInjection/Factory/MenuAdminFactory.php index c5ac6cd..5542525 100644 --- a/src/DependencyInjection/Factory/MenuAdminFactory.php +++ b/src/DependencyInjection/Factory/MenuAdminFactory.php @@ -38,6 +38,7 @@ public function addConfiguration(NodeBuilder $builder) { $builder ->booleanNode('recursive_breadcrumbs')->defaultTrue()->end() + ->booleanNode('use_burgov_keyvalue_form')->defaultFalse()->end() ->arrayNode('extensions') ->addDefaultsIfNotSet() ->children() @@ -72,6 +73,7 @@ public function create(array $config, ContainerBuilder $container, XmlFileLoader $loader->load('menu.xml'); $this->loadExtensions($config['extensions'], $container, $loader); + $this->loadBurgovKeyValueForm($container); } private function loadExtensions(array $config, ContainerBuilder $container, XmlFileLoader $loader) @@ -101,4 +103,11 @@ private function loadExtensions(array $config, ContainerBuilder $container, XmlF } } } + + private function loadBurgovKeyValueForm(ContainerBuilder $container) + { + $bundles = $container->getParameter('kernel.bundles'); + + $container->setParameter('cmf_sonata_phpcr_admin_integration.menu.use_burgov_keyvalue_form', isset($bundles['BurgovKeyValueFormBundle']) ); + } } diff --git a/src/Resources/config/menu.xml b/src/Resources/config/menu.xml index 773a82f..f6a7514 100644 --- a/src/Resources/config/menu.xml +++ b/src/Resources/config/menu.xml @@ -69,8 +69,8 @@ %cmf_sonata_phpcr_admin_integration.menu.recursive_breadcrumbs% - - %cmf_sonata_phpcr_admin_integration.menu.extension.menu_options.advanced% + + %cmf_sonata_phpcr_admin_integration.menu.use_burgov_keyvalue_form%