Created
October 14, 2015 18:17
-
-
Save Maff-/91a732db779c7c507b05 to your computer and use it in GitHub Desktop.
Let a Symfony bundle configure their own Doctrine EnumTypes via the PrependExtensionInterface
This file contains hidden or 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
<?php | |
namespace AppBundle\DependencyInjection; | |
use Symfony\Component\DependencyInjection\ContainerBuilder; | |
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; | |
use Symfony\Component\HttpKernel\DependencyInjection\Extension; | |
class AppExtension extends Extension implements PrependExtensionInterface | |
{ | |
/** | |
* @inheritdoc | |
*/ | |
public function load(array $config, ContainerBuilder $container) | |
{ | |
// Do nothing, we only care about the prepend functionality (for this demo) | |
} | |
/** | |
* @inheritdoc | |
*/ | |
public function prepend(ContainerBuilder $container) | |
{ | |
$container->prependExtensionConfig('doctrine', [ | |
'dbal' => [ | |
'types' => [ | |
'BookFormatType' => 'AppBundle\DBAL\Types\BookFormatType', | |
// ... all of our bundle's Enums | |
] | |
] | |
]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment