Initial commit

This commit is contained in:
Antoine Hérault
2011-05-08 23:04:37 +02:00
commit ae7440f4d7
22 changed files with 1019 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
<?php
namespace Knplabs\Bundle\GaufretteBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
/**
* Compiler pass that registers the adapter factories
*
* @author Antoine Hérault <antoine.herault@gmail.com>
*/
class AdapterFactoryManagerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
if (!$container->hasDefinition('knplabs_gaufrette.adapter_factory_manager')) {
return;
}
$definition = $container->getDefinition('knplabs_gaufrette.adapter_factory_manager');
$calls = $definition->getMethodCalls();
$definition->setMethodCalls(array());
foreach ($container->findTaggedServiceIds('gaufrette.adapter_factory') as $id => $attributes) {
if (!empty($attributes['type'])) {
$definition->addMethodCall('set', array($attributes['type'], new Reference($id)));
}
}
$definition->setMethodCalls(array_merge($definition->getMethodCalls(), $calls));
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace Knplabs\Bundle\GaufretteBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
/**
* Compiler pass that registers the adapters
*
* @author Antoine Hérault <antoine.herault@gmail.com>
*/
class AdapterManagerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
if (!$container->hasDefinition('knplabs_gaufrette.adapter_manager')) {
return;
}
$definition = $container->getDefinition('knplabs_gaufrette.adapter_manager');
$calls = $definition->getMethodCalls();
$definition->setMethodCalls(array());
foreach ($container->findTaggedServiceIds('gaufrette.adapter') as $id => $attributes) {
if (!empty($attributes['alias'])) {
$definition->addMethodCall('set', array($attributes['alias'], new Reference($id)));
}
}
$definition->setMethodCalls(array_merge($definition->getMethodCalls(), $calls));
}
}