vendor/nellapp/sdk-bundle/src/NellappSDKBundle.php line 11

Open in your IDE?
  1. <?php
  2. namespace Nellapp\Bundle\SDKBundle;
  3. use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass;
  4. use Nellapp\Bundle\SDKBundle\DependencyInjection\Compiler\GlobalEntityPass;
  5. use Nellapp\Bundle\SDKBundle\GlobalGetters\GlobalEntityKeys;
  6. use Symfony\Component\DependencyInjection\ContainerBuilder;
  7. use Symfony\Component\HttpKernel\Bundle\Bundle;
  8. class NellappSDKBundle extends Bundle
  9. {
  10.     public function build(ContainerBuilder $container)
  11.     {
  12.         $container->addCompilerPass(new GlobalEntityPass());
  13.         $this->doctrineMappingConfig($container);
  14.         foreach (GlobalEntityKeys::GLOBAL_REPOSITORIES as $globalKey => $globalRepository) {
  15.             if ($globalRepository !== null) {
  16.                 $container->registerForAutoconfiguration($globalRepository)
  17.                     ->addTag(sprintf(GlobalEntityPass::REPOSITORY_TAG_NAME$globalKey));
  18.             }
  19.         }
  20.     }
  21.     private function doctrineMappingConfig(ContainerBuilder $container): void
  22.     {
  23.         $configs = [
  24.             'nellapp_sdk.auth.enable' => [
  25.                 'namespaces' => [
  26.                     'Nellapp\Bundle\SDKBundle\Auth\Entity',
  27.                 ],
  28.                 'directories' => [
  29.                     realpath(__DIR__ '/Auth/Entity'),
  30.                 ],
  31.             ],
  32.             'nellapp_sdk.channel.enable' => [
  33.                 'namespaces' => [
  34.                     'Nellapp\Bundle\SDKBundle\Channel\Entity',
  35.                 ],
  36.                 'directories' => [
  37.                     realpath(__DIR__ '/Channel/Entity'),
  38.                 ],
  39.             ],
  40.             [
  41.                 'namespaces' => [
  42.                     'Nellapp\Bundle\SDKBundle\Permission\Entity',
  43.                 ],
  44.                 'directories' => [
  45.                     realpath(__DIR__ '/Permission/Entity'),
  46.                 ]
  47.             ]
  48.         ];
  49.         foreach ($configs as $param => $config) {
  50.             $container->addCompilerPass(DoctrineOrmMappingsPass::createAttributeMappingDriver(
  51.                 namespaces$config['namespaces'],
  52.                 directories$config['directories'],
  53.                 enabledParameteris_string($param) ? $param false,
  54.             ));
  55.         }
  56.     }
  57. }