瀏覽代碼

Configuration PietroBundle

master
Guillaume 3 年之前
當前提交
adf62dfef6
共有 3 個檔案被更改,包括 72 行新增0 行删除
  1. +25
    -0
      DependencyInjection/Configuration.php
  2. +33
    -0
      DependencyInjection/LcPietroExtension.php
  3. +14
    -0
      LcPietroBundle.php

+ 25
- 0
DependencyInjection/Configuration.php 查看文件

@@ -0,0 +1,25 @@
<?php

namespace Lc\PietroBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

/**
* This is the class that validates and merges configuration from your app/config files
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
*/
class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('lc_pietro');
$rootNode = $treeBuilder->getRootNode();

return $treeBuilder;
}
}

+ 33
- 0
DependencyInjection/LcPietroExtension.php 查看文件

@@ -0,0 +1,33 @@
<?php

namespace Lc\PietroBundle\DependencyInjection;

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;

class LcPietroExtension extends Extension implements PrependExtensionInterface
{

public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

foreach ($config as $parameter => $value) {
$container->setParameter(sprintf('lc_pietro.%s', $parameter), $value);
}

$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yaml');
}

public function prepend(ContainerBuilder $container)
{
/*$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config/easy_admin'));
$loader->load('base.yaml');
$loader->load('entities/merchant.yaml');*/
}
}

+ 14
- 0
LcPietroBundle.php 查看文件

@@ -0,0 +1,14 @@
<?php

namespace Lc\PietroBundle;

use Lc\PietroBundle\DependencyInjection\LcPietroExtension;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class LcPietroBundle extends Bundle
{
public function getContainerExtension()
{
return new LcPietroExtension();
}
}

Loading…
取消
儲存