|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Prokl\BitrixOrdinaryToolsBundle\DependencyInjection; |
| 4 | + |
| 5 | +use Exception; |
| 6 | +use LogicException; |
| 7 | +use Symfony\Component\Config\FileLocator; |
| 8 | +use Symfony\Component\DependencyInjection\ContainerBuilder; |
| 9 | +use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
| 10 | +use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
| 11 | + |
| 12 | +/** |
| 13 | + * Class BitrixOrdinaryToolsExtension |
| 14 | + * @package Prokl\BitrixOrdinaryTools\DependencyInjection |
| 15 | + * |
| 16 | + * @since 19.05.2021 |
| 17 | + */ |
| 18 | +class BitrixOrdinaryToolsExtension extends Extension |
| 19 | +{ |
| 20 | + private const DIR_CONFIG = '/../Resources/config'; |
| 21 | + |
| 22 | + /** |
| 23 | + * @inheritDoc |
| 24 | + * @throws Exception | LogicException |
| 25 | + */ |
| 26 | + public function load(array $configs, ContainerBuilder $container) : void |
| 27 | + { |
| 28 | + $loader = new YamlFileLoader( |
| 29 | + $container, |
| 30 | + new FileLocator(__DIR__ . self::DIR_CONFIG) |
| 31 | + ); |
| 32 | + |
| 33 | + $loader->load('services.yaml'); |
| 34 | + $loader->load('seo.yaml'); |
| 35 | + $loader->load('image_resizer.yaml'); |
| 36 | + |
| 37 | + if (!class_exists('Prokl\CustomFrameworkExtensionsBundle\DependencyInjection\CustomFrameworkExtensionsExtension')) { |
| 38 | + throw new LogicException( |
| 39 | + 'Чтобы использовать Твиг нужно установить и активировать core.framework.extension.bundle. |
| 40 | + Попробуйте composer require proklung/core-framework-extension-bundle.' |
| 41 | + ); |
| 42 | + } |
| 43 | + |
| 44 | + $loader->load('twig.yaml'); |
| 45 | + |
| 46 | + // Фасады подтягиваются только, если установлен соответствующий бандл. |
| 47 | + if (class_exists('Prokl\FacadeBundle\Services\AbstractFacade')) { |
| 48 | + $loader->load('facades.yaml'); |
| 49 | + } |
| 50 | + } |
| 51 | + |
| 52 | + /** |
| 53 | + * @inheritDoc |
| 54 | + */ |
| 55 | + public function getAlias() : string |
| 56 | + { |
| 57 | + return 'bitrix-ordinary-tools'; |
| 58 | + } |
| 59 | +} |
0 commit comments