forked from sonata-project/SonataAdminBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SonataAdminBundle.php
92 lines (81 loc) · 3.82 KB
/
SonataAdminBundle.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
/*
* This file is part of the Sonata Project package.
*
* (c) Thomas Rabaix <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sonata\AdminBundle;
use Sonata\AdminBundle\DependencyInjection\Compiler\AddDependencyCallsCompilerPass;
use Sonata\AdminBundle\DependencyInjection\Compiler\AddFilterTypeCompilerPass;
use Sonata\AdminBundle\DependencyInjection\Compiler\ExtensionCompilerPass;
use Sonata\AdminBundle\DependencyInjection\Compiler\GlobalVariablesCompilerPass;
use Sonata\CoreBundle\Form\FormHelper;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class SonataAdminBundle extends Bundle
{
/**
* {@inheritdoc}
*/
public function build(ContainerBuilder $container)
{
$container->addCompilerPass(new AddDependencyCallsCompilerPass());
$container->addCompilerPass(new AddFilterTypeCompilerPass());
$container->addCompilerPass(new ExtensionCompilerPass());
$container->addCompilerPass(new GlobalVariablesCompilerPass());
$this->registerFormMapping();
}
/**
* {@inheritdoc}
*/
public function boot()
{
$this->registerFormMapping();
}
/**
* Register form mapping information.
*/
public function registerFormMapping()
{
FormHelper::registerFormTypeMapping(array(
'sonata_type_admin' => 'Sonata\AdminBundle\Form\Type\AdminType',
'sonata_type_model' => 'Sonata\AdminBundle\Form\Type\ModelType',
'sonata_type_model_list' => 'Sonata\AdminBundle\Form\Type\ModelTypeList',
'sonata_type_model_reference' => 'Sonata\AdminBundle\Form\Type\ModelReferenceType',
'sonata_type_model_hidden' => 'Sonata\AdminBundle\Form\Type\ModelHiddenType',
'sonata_type_model_autocomplete' => 'Sonata\AdminBundle\Form\Type\ModelAutocompleteType',
'sonata_type_native_collection' => 'Sonata\AdminBundle\Form\Type\CollectionType',
'sonata_type_choice_field_mask' => 'Sonata\AdminBundle\Form\Type\ChoiceFieldMaskType',
'sonata_type_filter_number' => 'Sonata\AdminBundle\Form\Type\Filter\NumberType',
'sonata_type_filter_choice' => 'Sonata\AdminBundle\Form\Type\Filter\ChoiceType',
'sonata_type_filter_default' => 'Sonata\AdminBundle\Form\Type\Filter\DefaultType',
'sonata_type_filter_date' => 'Sonata\AdminBundle\Form\Type\Filter\DateType',
'sonata_type_filter_date_range' => 'Sonata\AdminBundle\Form\Type\Filter\DateRangeType',
'sonata_type_filter_datetime' => 'Sonata\AdminBundle\Form\Type\Filter\DateTimeType',
'sonata_type_filter_datetime_range' => 'Sonata\AdminBundle\Form\Type\Filter\DateTimeRangeType',
'tab' => 'Mopa\Bundle\BootstrapBundle\Form\Type\TabType',
));
FormHelper::registerFormExtensionMapping('form', array(
'sonata.admin.form.extension.field',
'mopa_bootstrap.form.type_extension.help',
'mopa_bootstrap.form.type_extension.legend',
'mopa_bootstrap.form.type_extension.error',
'mopa_bootstrap.form.type_extension.widget',
'mopa_bootstrap.form.type_extension.horizontal',
'mopa_bootstrap.form.type_extension.widget_collection',
'mopa_bootstrap.form.type_extension.tabbed',
));
FormHelper::registerFormExtensionMapping('choice', array(
'sonata.admin.form.extension.choice',
));
FormHelper::registerFormExtensionMapping('button', array(
'mopa_bootstrap.form.type_extension.button',
));
FormHelper::registerFormExtensionMapping('date', array(
'mopa_bootstrap.form.type_extension.date',
));
}
}