Skip to content

Instantly share code, notes, and snippets.

@daum
Created March 4, 2013 16:05
Show Gist options
  • Save daum/5083295 to your computer and use it in GitHub Desktop.
Save daum/5083295 to your computer and use it in GitHub Desktop.
<?php
namespace Knp\Bundle\MenuBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
/**
* This compiler pass adds the path for the KnpMenu template in the twig loader.
*
* @author Christophe Coevoet <[email protected]>
*/
class AddTemplatePathPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
if (!$container->hasDefinition('twig.loader')) {
return;
}
$refl = new \ReflectionClass('Knp\Menu\ItemInterface');
$path = dirname($refl->getFileName()).'/Resources/views';
var_dump($path);die();
$container->getDefinition('twig.loader')->addMethodCall('addPath', array($path));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment