You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ApplicationDefinition.php 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. namespace Lc\SovBundle\Definition;
  3. use Lc\SovBundle\Container\ComponentContainer;
  4. use Lc\SovBundle\Container\File\FileContainer;
  5. use Lc\SovBundle\Container\Newsletter\NewsletterContainer;
  6. use Lc\SovBundle\Container\Reminder\ReminderContainer;
  7. use Lc\SovBundle\Container\Setting\SiteSettingContainer;
  8. use Lc\SovBundle\Container\Site\NewsContainer;
  9. use Lc\SovBundle\Container\Site\PageContainer;
  10. use Lc\SovBundle\Container\Site\SiteContainer;
  11. use Lc\SovBundle\Container\Ticket\TicketContainer;
  12. use Lc\SovBundle\Container\Ticket\TicketMessageContainer;
  13. use Lc\SovBundle\Container\User\GroupUserContainer;
  14. use Lc\SovBundle\Container\User\UserContainer;
  15. use function Symfony\Component\String\u;
  16. class ApplicationDefinition
  17. {
  18. public static function getContainerList(): array
  19. {
  20. return [
  21. FileContainer::class,
  22. NewsletterContainer::class,
  23. ReminderContainer::class,
  24. NewsContainer::class,
  25. PageContainer::class,
  26. SiteContainer::class,
  27. TicketContainer::class,
  28. TicketMessageContainer::class,
  29. GroupUserContainer::class,
  30. UserContainer::class,
  31. SiteSettingContainer::class,
  32. ComponentContainer::class
  33. ];
  34. }
  35. public function getContainerByEntityFqcn(string $entityFqcn)
  36. {
  37. foreach (static::getContainerList() as $containerFqcn){
  38. if($this->isContainerManageEntity($containerFqcn)){
  39. if ($containerFqcn::getEntityFqcn() == $entityFqcn) {
  40. return $containerFqcn;
  41. }
  42. }
  43. }
  44. return null;
  45. }
  46. public function isContainerManageEntity(string $containerFqcn)
  47. {
  48. if(method_exists($containerFqcn, 'getEntityFqcn') ){
  49. return true;
  50. }
  51. return false;
  52. }
  53. public static function getSubscribedContainerServices(): array
  54. {
  55. $array = [];
  56. foreach (static::getContainerList() as $container) {
  57. $array[$container] = $container;
  58. }
  59. return $array;
  60. }
  61. public static function getContainerListForTwigGlobals(): array
  62. {
  63. $array = [];
  64. foreach (static::getContainerList() as $containerNamespace) {
  65. //récupère le nom du fichier dans le namespace du container
  66. $key = u(substr($containerNamespace, strrpos($containerNamespace, '\\')))->snake();
  67. $array[$key->toString()] = '@' . $containerNamespace;
  68. }
  69. return $array;
  70. }
  71. }