From abd70ec474d80aa9047062d90bb5822000dca779 Mon Sep 17 00:00:00 2001 From: Etienne Gutbub Date: Tue, 8 Oct 2024 14:30:09 +0200 Subject: [PATCH] feat(LinkType): Add a new form type LinkType that should be used for urls --- src/Form/Type/LinkType.php | 24 ++++++++++++++++++++++ src/Form/Type/UiElement/ButtonLinkType.php | 4 ++-- src/Form/Type/UiElement/ImageType.php | 4 ++-- 3 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 src/Form/Type/LinkType.php diff --git a/src/Form/Type/LinkType.php b/src/Form/Type/LinkType.php new file mode 100644 index 00000000..f64db2dc --- /dev/null +++ b/src/Form/Type/LinkType.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace MonsieurBiz\SyliusRichEditorPlugin\Form\Type; + +use Symfony\Component\Form\Extension\Core\Type\TextType; + +final class LinkType extends TextType +{ + /** + * At the moment just like a TextType but in addition with the Plugin Monsieurbiz/SyliusMenuPlugin + * it will allow us to add a button to choose the target of the link on all rich editor fields that should have an URL. + */ +} diff --git a/src/Form/Type/UiElement/ButtonLinkType.php b/src/Form/Type/UiElement/ButtonLinkType.php index 47a474e9..e87ae114 100644 --- a/src/Form/Type/UiElement/ButtonLinkType.php +++ b/src/Form/Type/UiElement/ButtonLinkType.php @@ -15,9 +15,9 @@ use MonsieurBiz\SyliusRichEditorPlugin\Form\Type\AlignmentType; use MonsieurBiz\SyliusRichEditorPlugin\Form\Type\LevelType; +use MonsieurBiz\SyliusRichEditorPlugin\Form\Type\LinkType; use MonsieurBiz\SyliusRichEditorPlugin\Form\Type\LinkTypeType; use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\TextType as FormTextType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Validator\Constraints as Assert; @@ -69,7 +69,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'label' => 'monsieurbiz_richeditor_plugin.ui_element.monsieurbiz.button.field.label', 'constraints' => $constraintsLabel, ]) - ->add('link', TextType::class, [ + ->add('link', LinkType::class, [ 'required' => $required, 'label' => 'monsieurbiz_richeditor_plugin.ui_element.monsieurbiz.button.field.link', 'constraints' => $constraintsLink, diff --git a/src/Form/Type/UiElement/ImageType.php b/src/Form/Type/UiElement/ImageType.php index c6d7b52b..22eda270 100644 --- a/src/Form/Type/UiElement/ImageType.php +++ b/src/Form/Type/UiElement/ImageType.php @@ -16,12 +16,12 @@ use MonsieurBiz\SyliusMediaManagerPlugin\Form\Type\ImageType as MediaManagerImageType; use MonsieurBiz\SyliusRichEditorPlugin\Form\Constraints\RichEditorConstraints; use MonsieurBiz\SyliusRichEditorPlugin\Form\Type\AlignmentType; +use MonsieurBiz\SyliusRichEditorPlugin\Form\Type\LinkType; use MonsieurBiz\SyliusRichEditorPlugin\Form\Type\LinkTypeType; use MonsieurBiz\SyliusRichEditorPlugin\MonsieurBizSyliusRichEditorPlugin; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\FileType; use Symfony\Component\Form\Extension\Core\Type\TextType as FormTextType; -use Symfony\Component\Form\Extension\Core\Type\UrlType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvents; @@ -58,7 +58,7 @@ public function addFields(FormBuilderInterface $builder, array $options): void 'required' => false, 'label' => 'monsieurbiz_richeditor_plugin.ui_element.monsieurbiz.image.field.title', ]) - ->add('link', UrlType::class, [ + ->add('link', LinkType::class, [ 'required' => false, 'label' => 'monsieurbiz_richeditor_plugin.ui_element.monsieurbiz.image.field.link', 'constraints' => [