|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Evheniy\MaterializeBundle\DependencyInjection; |
|
4
|
|
|
|
|
5
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
6
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
|
7
|
|
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
|
8
|
|
|
use Symfony\Component\Config\FileLocator; |
|
9
|
|
|
use Symfony\Component\Config\Definition\Processor; |
|
10
|
|
|
use Evheniy\JqueryBundle\Helper\CdnHelper; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Class MaterializeExtension |
|
14
|
|
|
* |
|
15
|
|
|
* @package Evheniy\MaterializeBundle\DependencyInjection |
|
16
|
|
|
*/ |
|
17
|
|
|
class MaterializeExtension extends Extension |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @param array $configs |
|
21
|
|
|
* @param ContainerBuilder $container |
|
22
|
|
|
*/ |
|
23
|
|
|
public function load(array $configs, ContainerBuilder $container) |
|
24
|
|
|
{ |
|
25
|
|
|
$processor = new Processor(); |
|
26
|
|
|
$configuration = new Configuration(); |
|
27
|
|
|
$config = $processor->processConfiguration($configuration, $configs); |
|
28
|
|
|
$config['local_cdn'] = CdnHelper::createInstance()->filterCdn($config['local_cdn']); |
|
29
|
|
|
$container->setParameter('materialize', $config); |
|
30
|
|
|
$container->setParameter('materialize.local_js', $config['local_js']); |
|
31
|
|
|
$container->setParameter('materialize.local_fonts_dir', $config['local_fonts_dir']); |
|
32
|
|
|
$container->setParameter('materialize.local_css', $config['local_css']); |
|
33
|
|
|
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
|
34
|
|
|
$loader->load('services.yml'); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @return string |
|
39
|
|
|
*/ |
|
40
|
|
|
public function getAlias() |
|
41
|
|
|
{ |
|
42
|
|
|
return 'materialize'; |
|
43
|
|
|
} |
|
44
|
|
|
} |
|
45
|
|
|
|