Skip to content

Commit

Permalink
kernel is not actually needed
Browse files Browse the repository at this point in the history
  • Loading branch information
sam0delkin committed Apr 1, 2015
1 parent 3dd94bb commit 60238fb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
13 changes: 3 additions & 10 deletions DependencyInjection/Compiler/AnnotationConfigurationPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,11 @@
use Symfony\Component\DependencyInjection\DefinitionDecorator;
use Symfony\Component\DependencyInjection\Definition;
use JMS\DiExtraBundle\Finder\PatternFinder;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

class AnnotationConfigurationPass implements CompilerPassInterface
{
private $kernel;

public function __construct(KernelInterface $kernel)
{
$this->kernel = $kernel;
}

public function process(ContainerBuilder $container)
{
$factory = $container->get('jms_di_extra.metadata.metadata_factory');
Expand Down Expand Up @@ -78,7 +70,7 @@ public function process(ContainerBuilder $container)

private function getScanDirectories(ContainerBuilder $c)
{
$bundles = $this->kernel->getBundles();
$bundles = $c->getParameter('kernel.bundles');
$scanBundles = $c->getParameter('jms_di_extra.bundles');
$scanAllBundles = $c->getParameter('jms_di_extra.all_bundles');

Expand All @@ -92,7 +84,8 @@ private function getScanDirectories(ContainerBuilder $c)
continue;
}

$directories[] = $bundle->getPath();
$reflected = new \ReflectionClass($bundle);
$directories[] = dirname($reflected->getFileName());
}

return $directories;
Expand Down
10 changes: 1 addition & 9 deletions JMSDiExtraBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,18 @@

use JMS\DiExtraBundle\DependencyInjection\Compiler\ResourceOptimizationPass;
use JMS\DiExtraBundle\DependencyInjection\Compiler\IntegrationPass;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
use JMS\DiExtraBundle\DependencyInjection\Compiler\AnnotationConfigurationPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class JMSDiExtraBundle extends Bundle
{
private $kernel;

public function __construct(KernelInterface $kernel)
{
$this->kernel = $kernel;
}

public function build(ContainerBuilder $container)
{
$config = $container->getCompiler()->getPassConfig();
$passes = $config->getBeforeOptimizationPasses();
array_unshift($passes, new AnnotationConfigurationPass($this->kernel));
array_unshift($passes, new AnnotationConfigurationPass());
$config->setBeforeOptimizationPasses($passes);

$container->addCompilerPass(new IntegrationPass());
Expand Down

0 comments on commit 60238fb

Please sign in to comment.