Skip to content

Instantly share code, notes, and snippets.

@winzou
Created May 14, 2011 14:23
Show Gist options
  • Save winzou/972258 to your computer and use it in GitHub Desktop.
Save winzou/972258 to your computer and use it in GitHub Desktop.
# winzouBookBundle
winzou_book:
entry:
entity:
class: Asso\BookBundle\Entity\Entry
manager:
class: Asso\BookBundle\Entity\Manager\EntryManager
services:
winzou_book.entry_manager:
class: %winzou_book.entry.manager.class%
arguments: [@doctrine.orm.entity_manager, %winzou_book.entry.entity.class%]
<?php
namespace winzou\BookBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
class Configuration
{
public function getConfigTree()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('winzou_book');
$rootNode
->children()
->arrayNode('entry')
->children()
->arrayNode('entity')
->children()
->scalarNode('class')->isRequired()->cannotBeEmpty()->end()
->end()
->end()
->arrayNode('manager')
->children()
->scalarNode('class')->defaultValue('winzou\\BookBundle\\Entity\\Manager\\EntryManager')->end()
->end()
->end()
->end()
->end()
->arrayNode('account')
->children()
->arrayNode('entity')
->children()
->scalarNode('class')->defaultValue('winzou\\BookBundle\\Entity\\Account')->end()
->end()
->end()
->arrayNode('manager')
->children()
->scalarNode('class')->defaultValue('winzou\\BookBundle\\Entity\\Manager\\AccountManager')->end()
->end()
->end()
->end()
->end()
->end();
return $treeBuilder->buildTree();
}
}
<?php
namespace winzou\BookBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\Config\FileLocator;
class winzouBookExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container)
{
$processor = new Processor();
$configuration = new Configuration();
$config = $processor->process($configuration->getConfigTree(), $configs);
var_dump($config);
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment