-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sf4 compat & refactor twig path override
* Allow Symfony 4 * Overrides Twig path for EasyAdmin namespace with a CompilerPass
- Loading branch information
Showing
5 changed files
with
62 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace AlterPHP\EasyAdminExtensionBundle\DependencyInjection\Compiler; | ||
|
||
use AlterPHP\EasyAdminExtensionBundle\EasyAdminExtensionBundle; | ||
use EasyCorp\Bundle\EasyAdminBundle\EasyAdminBundle; | ||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
class TwigPathPass implements CompilerPassInterface | ||
{ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
$twigLoaderFilesystemId = $container->getAlias('twig.loader')->__toString(); | ||
$twigLoaderFilesystemDefinition = $container->getDefinition($twigLoaderFilesystemId); | ||
|
||
// Replaces native EasyAdmin templates | ||
$easyAdminExtensionBundleRefl = new \ReflectionClass(EasyAdminExtensionBundle::class); | ||
$easyAdminExtensionBundlePath = dirname($easyAdminExtensionBundleRefl->getFilename()); | ||
$easyAdminExtensionTwigPath = $easyAdminExtensionBundlePath.'/Resources/views'; | ||
$twigLoaderFilesystemDefinition->addMethodCall('prependPath', array($easyAdminExtensionTwigPath, 'EasyAdmin')); | ||
|
||
$nativeEasyAdminBundleRefl = new \ReflectionClass(EasyAdminBundle::class); | ||
$nativeEasyAdminBundlePath = dirname($nativeEasyAdminBundleRefl->getFilename()); | ||
$nativeEasyAdminTwigPath = $nativeEasyAdminBundlePath.'/Resources/views'; | ||
// Defines a namespace from native EasyAdmin templates | ||
$twigLoaderFilesystemDefinition->addMethodCall('addPath', array($nativeEasyAdminTwigPath, 'BaseEasyAdmin')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters