1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Sylius package. |
5
|
|
|
* |
6
|
|
|
* (c) Paweł Jędrzejewski |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Sylius\Bundle\ThemeBundle\DependencyInjection; |
13
|
|
|
|
14
|
|
|
use Sylius\Bundle\ResourceBundle\DependencyInjection\Extension\AbstractResourceExtension; |
15
|
|
|
use Symfony\Component\Config\FileLocator; |
16
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
17
|
|
|
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @author Kamil Kokot <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
class SyliusThemeExtension extends AbstractResourceExtension |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* {@inheritdoc} |
26
|
|
|
*/ |
27
|
|
|
public function load(array $configs, ContainerBuilder $container) |
28
|
|
|
{ |
29
|
|
|
$config = $this->processConfiguration(new Configuration(), $configs); |
30
|
|
|
|
31
|
|
|
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config/services')); |
32
|
|
|
$loader->load('assets.xml'); |
33
|
|
|
$loader->load('configuration.xml'); |
34
|
|
|
$loader->load('resource_locators.xml'); |
35
|
|
|
$loader->load('services.xml'); |
36
|
|
|
$loader->load('templating.xml'); |
37
|
|
|
$loader->load('translations.xml'); |
38
|
|
|
|
39
|
|
|
// TODO: Interfaces ready for filesystem decoupling, configuration not ready yet |
40
|
|
|
$loader->load('filesystem_configuration.xml'); |
41
|
|
|
$container->setAlias('sylius.theme.configuration.loader', 'sylius.theme.configuration.loader.json_file'); |
42
|
|
|
$container->setAlias('sylius.theme.configuration.provider', 'sylius.theme.configuration.provider.filesystem'); |
43
|
|
|
|
44
|
|
|
$container->setParameter('sylius.theme.configuration.filesystem.locations', $config['sources']['filesystem']['locations']); |
45
|
|
|
|
46
|
|
|
$loader->load(sprintf('driver/%s.xml', $config['driver'])); |
47
|
|
|
$this->registerResources('sylius', $config['driver'], $config['resources'], $container); |
48
|
|
|
|
49
|
|
|
$container->setParameter('sylius.interface.theme.class', $config['resources']['theme']['classes']['interface']); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|