|
10 | 10 |
|
11 | 11 | namespace BitBag\SyliusCmsPlugin\Form\Type; |
12 | 12 |
|
13 | | -use FOS\CKEditorBundle\Form\Type\CKEditorType; |
| 13 | +use BitBag\SyliusCmsPlugin\Form\Type\Wysiwyg\WysiwygStrategyInterface; |
| 14 | +use BitBag\SyliusCmsPlugin\Resolver\WysiwygStrategyResolverInterface; |
14 | 15 | use Symfony\Component\Form\AbstractType; |
| 16 | +use Symfony\Component\Form\FormInterface; |
| 17 | +use Symfony\Component\Form\FormView; |
15 | 18 | use Symfony\Component\OptionsResolver\OptionsResolver; |
16 | | -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; |
17 | 19 |
|
18 | 20 | final class WysiwygType extends AbstractType |
19 | 21 | { |
20 | | - public function __construct(private UrlGeneratorInterface $urlGenerator) |
| 22 | + private WysiwygStrategyInterface $strategy; |
| 23 | + |
| 24 | + public function __construct(private WysiwygStrategyResolverInterface $strategyResolver) |
21 | 25 | { |
22 | 26 | } |
23 | 27 |
|
24 | 28 | public function configureOptions(OptionsResolver $resolver): void |
25 | 29 | { |
26 | | - $resolver->setDefaults([ |
27 | | - 'label' => 'bitbag_sylius_cms_plugin.ui.content', |
28 | | - 'config' => [ |
29 | | - 'filebrowserUploadUrl' => $this->urlGenerator->generate('bitbag_sylius_cms_plugin_admin_upload_editor_image'), |
30 | | - 'bodyId' => 'bitbag-ckeditor', |
31 | | - ], |
32 | | - ]); |
| 30 | + $this->strategy->configureOptions($resolver); |
| 31 | + } |
| 32 | + |
| 33 | + public function buildView(FormView $view, FormInterface $form, array $options): void |
| 34 | + { |
| 35 | + $this->strategy->buildView($view, $form, $options); |
33 | 36 | } |
34 | 37 |
|
35 | 38 | public function getParent(): string |
36 | 39 | { |
37 | | - return CKEditorType::class; |
| 40 | + return $this->strategy->getParent(); |
38 | 41 | } |
39 | 42 |
|
40 | 43 | public function getBlockPrefix(): string |
41 | 44 | { |
42 | | - return 'bitbag_wysiwyg'; |
| 45 | + return $this->strategy->getBlockPrefix(); |
| 46 | + } |
| 47 | + |
| 48 | + public function setStrategy(string $strategy): void |
| 49 | + { |
| 50 | + $this->strategy = $this->strategyResolver->getStrategy($strategy); |
43 | 51 | } |
44 | 52 | } |
0 commit comments