Skip to content

Instantly share code, notes, and snippets.

@ismail1432
Created December 28, 2021 22:52
Show Gist options
  • Select an option

  • Save ismail1432/f2fd80c0290773d2bb12a4c8e7a23a6c to your computer and use it in GitHub Desktop.

Select an option

Save ismail1432/f2fd80c0290773d2bb12a4c8e7a23a6c to your computer and use it in GitHub Desktop.
<?php
namespace App;
use App\DoctrineType\AbstractEnumType;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
class Kernel extends BaseKernel implements CompilerPassInterface
{
use MicroKernelTrait;
public function process(ContainerBuilder $container): void
{
$typesDefinition = [];
if ($container->hasParameter('doctrine.dbal.connection_factory.types')) {
$typesDefinition = $container->getParameter('doctrine.dbal.connection_factory.types');
}
$taggedEnums = $container->findTaggedServiceIds('app.doctrine_enum_type');
foreach ($taggedEnums as $enumType => $definition) {
/** @var $enumType AbstractEnumType */
$typesDefinition[$enumType::NAME] = ['class' => $enumType];
}
$container->setParameter('doctrine.dbal.connection_factory.types', $typesDefinition);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment