This repository has been archived by the owner on Mar 17, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
ZenstruckFormExtension.php
executable file
·56 lines (46 loc) · 2.04 KB
/
ZenstruckFormExtension.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
<?php
namespace Zenstruck\Bundle\FormBundle\DependencyInjection;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Definition\Processor;
/**
* @author Kevin Bond <kevinbond@gmail.com>
*/
class ZenstruckFormExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container)
{
$processor = new Processor();
$configuration = new Configuration();
$config = $processor->processConfiguration($configuration, $configs);
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
if ($config['form_types']['help']) {
$loader->load('help_type.xml');
}
if ($config['form_types']['group']) {
$bundles = $container->getParameter('kernel.bundles');
if (!isset($bundles['ZenstruckSlugifyBundle']) && !isset($bundles['CocurSlugifyBundle'])) {
throw new \Exception('ZenstruckSlugifyBundle or CocurSlugifyBundle must be installed in order to use the "group" type.');
}
$loader->load('group_type.xml');
}
if ($config['form_types']['theme']) {
$container->setParameter('zenstruck_form.theme_options', $config['theme_options']);
$loader->load('theme_type.xml');
}
if ($config['form_types']['ajax_entity']) {
$loader->load('ajax_entity_type.xml');
}
if ($config['form_types']['ajax_entity_controller']) {
if (!class_exists('\Zend\Crypt\BlockCipher')) {
throw new \Exception('zendframework/zend-crypt must be installed to use the ajax_entity_controller feature.');
}
$loader->load('ajax_entity_controller.xml');
}
if ($config['form_types']['tunnel_entity']) {
$loader->load('tunnel_entity_type.xml');
}
}
}