Skip to content

Instantly share code, notes, and snippets.

@Maff-
Created October 14, 2015 18:17
Show Gist options
  • Save Maff-/91a732db779c7c507b05 to your computer and use it in GitHub Desktop.
Save Maff-/91a732db779c7c507b05 to your computer and use it in GitHub Desktop.
Let a Symfony bundle configure their own Doctrine EnumTypes via the PrependExtensionInterface
<?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