1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Sonata Project package. |
7
|
|
|
* |
8
|
|
|
* (c) Thomas Rabaix <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Sonata\NewsBundle; |
15
|
|
|
|
16
|
|
|
use Sonata\CoreBundle\Form\FormHelper; |
17
|
|
|
use Sonata\NewsBundle\DependencyInjection\Compiler\TwigStringExtensionCompilerPass; |
18
|
|
|
use Symfony\Component\DependencyInjection\Compiler\PassConfig; |
19
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
20
|
|
|
use Symfony\Component\HttpKernel\Bundle\Bundle; |
21
|
|
|
|
22
|
|
|
class SonataNewsBundle extends Bundle |
23
|
|
|
{ |
24
|
|
|
public function build(ContainerBuilder $container): void |
25
|
|
|
{ |
26
|
|
|
$container->addCompilerPass(new TwigStringExtensionCompilerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 1); |
27
|
|
|
|
28
|
|
|
$this->registerFormMapping(); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function boot(): void |
32
|
|
|
{ |
33
|
|
|
$this->registerFormMapping(); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Register form mapping information. |
38
|
|
|
*/ |
39
|
|
|
public function registerFormMapping(): void |
40
|
|
|
{ |
41
|
|
|
if (class_exists(FormHelper::class)) { |
42
|
|
|
FormHelper::registerFormTypeMapping([ |
43
|
|
|
'sonata_post_comment' => 'Sonata\NewsBundle\Form\Type\CommentType', |
44
|
|
|
'sonata_news_comment_status' => 'Sonata\NewsBundle\Form\Type\CommentStatusType', |
45
|
|
|
'sonata_news_api_form_comment' => 'Sonata\NewsBundle\Form\Type\ApiCommentType', |
46
|
|
|
'sonata_news_api_form_post' => 'Sonata\NewsBundle\Form\Type\ApiPostType', |
47
|
|
|
]); |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|