Skip to content

Commit 7681c39

Browse files
author
Quan Weiwei
committed
recipe config remove form_theme, so add global form_theme to twig by CompilePass
1 parent bef106f commit 7681c39

4 files changed

Lines changed: 29 additions & 10 deletions

File tree

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,6 @@ teebb_tui_editor:
101101
- mark
102102
- table
103103

104-
105-
twig:
106-
form_themes:
107-
- '@TeebbTuiEditor/Form/tuieditor_widget.html.twig'
108-
109104
```
110105
You can config tui.editor language.
111106
```yaml

README_zh.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,6 @@ teebb_tui_editor:
9797
- mark
9898
- table
9999

100-
101-
twig:
102-
form_themes:
103-
- '@TeebbTuiEditor/Form/tuieditor_widget.html.twig'
104-
105100
```
106101
您可以修改tui.editor的语言显示。
107102
```yaml
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
4+
namespace Teebb\TuiEditorBundle\DependencyInjection\Compile;
5+
6+
7+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
8+
use Symfony\Component\DependencyInjection\ContainerBuilder;
9+
10+
class TwigFormThemeCompilePass implements CompilerPassInterface
11+
{
12+
13+
public function process(ContainerBuilder $container)
14+
{
15+
//add tuieditor_widget.html.twig to form_theme
16+
$form_theme_old = $container->getParameter('twig.form.resources');
17+
$form_theme = array_merge($form_theme_old, ['@TeebbTuiEditor/Form/tuieditor_widget.html.Twig']);
18+
19+
$container->getDefinition('twig.form.engine')->replaceArgument(0, $form_theme);
20+
}
21+
}

src/TeebbTuiEditorBundle.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@
22

33
namespace Teebb\TuiEditorBundle;
44

5+
use Symfony\Component\DependencyInjection\ContainerBuilder;
56
use Symfony\Component\HttpKernel\Bundle\Bundle;
7+
use Teebb\TuiEditorBundle\DependencyInjection\Compile\TwigFormThemeCompilePass;
68

79
class TeebbTuiEditorBundle extends Bundle
810
{
11+
public function build(ContainerBuilder $container)
12+
{
13+
$container->addCompilerPass(new TwigFormThemeCompilePass());
14+
15+
parent::build($container); // TODO: Change the autogenerated stub
16+
}
917

1018
}

0 commit comments

Comments
 (0)