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.activity_feed.enable' => [
  28. 'namespaces' => [
  29. 'Nellapp\Bundle\SDKBundle\ActivityFeed\Entity',
  30. ],
  31. 'directories' => [
  32. realpath(__DIR__ . '/ActivityFeed/Entity'),
  33. ]
  34. ],
  35. 'nellapp_sdk.auth.enable' => [
  36. 'namespaces' => [
  37. 'Nellapp\Bundle\SDKBundle\Auth\Entity',
  38. ],
  39. 'directories' => [
  40. realpath(__DIR__ . '/Auth/Entity'),
  41. ],
  42. ],
  43. 'nellapp_sdk.channel.enable' => [
  44. 'namespaces' => [
  45. 'Nellapp\Bundle\SDKBundle\Channel\Entity',
  46. ],
  47. 'directories' => [
  48. realpath(__DIR__ . '/Channel/Entity'),
  49. ],
  50. ],
  51. [
  52. 'namespaces' => [
  53. 'Nellapp\Bundle\SDKBundle\Permission\Entity',
  54. ],
  55. 'directories' => [
  56. realpath(__DIR__ . '/Permission/Entity'),
  57. ]
  58. ],
  59. 'nellapp_sdk.google.enable' => [
  60. 'namespaces' => [
  61. 'Nellapp\Bundle\SDKBundle\Google\Entity',
  62. ],
  63. 'directories' => [
  64. realpath(__DIR__ . '/Google/Entity'),
  65. ]
  66. ]
  67. ];
  68. foreach ($configs as $param => $config) {
  69. $container->addCompilerPass(DoctrineOrmMappingsPass::createAttributeMappingDriver(
  70. namespaces: $config['namespaces'],
  71. directories: $config['directories'],
  72. enabledParameter: is_string($param) ? $param : false,
  73. ));
  74. }
  75. }
  76. }