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

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