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

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