Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

190 lines
6.3KB

  1. <?php
  2. namespace Lc\SovBundle\Controller;
  3. use Doctrine\ORM\EntityManagerInterface;
  4. use Knp\Component\Pager\PaginatorInterface;
  5. use Lc\SovBundle\Container\ComponentContainer;
  6. use Lc\SovBundle\Container\File\FileContainer;
  7. use Lc\SovBundle\Container\Newsletter\NewsletterContainer;
  8. use Lc\SovBundle\Container\Reminder\ReminderContainer;
  9. use Lc\SovBundle\Container\Setting\SiteSettingContainer;
  10. use Lc\SovBundle\Container\Site\NewsContainer;
  11. use Lc\SovBundle\Container\Site\PageContainer;
  12. use Lc\SovBundle\Container\Site\SiteContainer;
  13. use Lc\SovBundle\Container\Ticket\TicketContainer;
  14. use Lc\SovBundle\Container\Ticket\TicketMessageContainer;
  15. use Lc\SovBundle\Container\User\GroupUserContainer;
  16. use Lc\SovBundle\Container\User\UserContainer;
  17. use Lc\SovBundle\Solver\Setting\SettingSolver;
  18. use Psr\Log\LoggerInterface;
  19. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController as SfAbstractController;
  20. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  21. use Symfony\Component\HttpFoundation\Request;
  22. use Symfony\Component\HttpFoundation\RequestStack;
  23. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  24. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  25. use Symfony\Component\Security\Core\Security;
  26. use Symfony\Contracts\Translation\TranslatorInterface;
  27. use Twig\Environment;
  28. class AbstractController extends SfAbstractController
  29. {
  30. public static function getSubscribedServices()
  31. {
  32. return array_merge(
  33. parent::getSubscribedServices(),
  34. [
  35. Environment::class => Environment::class,
  36. Security::class => Security::class,
  37. EntityManagerInterface::class => EntityManagerInterface::class,
  38. UrlGeneratorInterface::class => UrlGeneratorInterface::class,
  39. SessionInterface::class => SessionInterface::class,
  40. PaginatorInterface::class => PaginatorInterface::class,
  41. RequestStack::class => RequestStack::class,
  42. EventDispatcherInterface::class => EventDispatcherInterface::class,
  43. TranslatorInterface::class => TranslatorInterface::class,
  44. LoggerInterface::class => LoggerInterface::class,
  45. SettingSolver::class => SettingSolver::class,
  46. ComponentContainer::class => ComponentContainer::class,
  47. FileContainer::class => FileContainer::class,
  48. NewsletterContainer::class => NewsletterContainer::class,
  49. ReminderContainer::class => ReminderContainer::class,
  50. NewsContainer::class => NewsContainer::class,
  51. PageContainer::class => PageContainer::class,
  52. SiteContainer::class => SiteContainer::class,
  53. TicketContainer::class => TicketContainer::class,
  54. TicketMessageContainer::class => TicketMessageContainer::class,
  55. GroupUserContainer::class => GroupUserContainer::class,
  56. UserContainer::class => UserContainer::class,
  57. SiteSettingContainer::class => SiteSettingContainer::class,
  58. ]
  59. );
  60. }
  61. public function getReferer(Request $request): ?string
  62. {
  63. return $request->headers->get('referer');
  64. }
  65. public function getTemplating(): Environment
  66. {
  67. return $this->get(Environment::class);
  68. }
  69. public function getEntityManager(): EntityManagerInterface
  70. {
  71. return $this->get(EntityManagerInterface::class);
  72. }
  73. public function getRouter(): UrlGeneratorInterface
  74. {
  75. return $this->get(UrlGeneratorInterface::class);
  76. }
  77. public function getSession(): SessionInterface
  78. {
  79. return $this->get(SessionInterface::class);
  80. }
  81. public function getSecurity(): Security
  82. {
  83. return $this->get(Security::class);
  84. }
  85. public function getPaginator(): PaginatorInterface
  86. {
  87. return $this->get(PaginatorInterface::class);
  88. }
  89. public function getRequestStack(): RequestStack
  90. {
  91. return $this->get(RequestStack::class);
  92. }
  93. public function getEventDispatcher(): EventDispatcherInterface
  94. {
  95. return $this->get(EventDispatcherInterface::class);
  96. }
  97. public function getTranslator(): TranslatorInterface
  98. {
  99. return $this->get(TranslatorInterface::class);
  100. }
  101. public function getLogger(): LoggerInterface
  102. {
  103. return $this->get(LoggerInterface::class);
  104. }
  105. public function getSettingSolver(): SettingSolver
  106. {
  107. return $this->get(SettingSolver::class);
  108. }
  109. public function getSettingValue($entity, $settingName)
  110. {
  111. return $this->getSettingSolver()->getSettingValue($entity, $settingName);
  112. }
  113. public function getComponentContainer(): ComponentContainer
  114. {
  115. return $this->get(ComponentContainer::class);
  116. }
  117. public function getFileContainer(): FileContainer
  118. {
  119. return $this->get(FileContainer::class);
  120. }
  121. public function getNewsletterContainer(): NewsletterContainer
  122. {
  123. return $this->get(NewsletterContainer::class);
  124. }
  125. public function getReminderContainer(): ReminderContainer
  126. {
  127. return $this->get(ReminderContainer::class);
  128. }
  129. public function getNewsContainer(): NewsContainer
  130. {
  131. return $this->get(NewsContainer::class);
  132. }
  133. public function getPageContainer(): PageContainer
  134. {
  135. return $this->get(PageContainer::class);
  136. }
  137. public function getSiteContainer(): SiteContainer
  138. {
  139. return $this->get(SiteContainer::class);
  140. }
  141. public function getTicketContainer(): TicketContainer
  142. {
  143. return $this->get(TicketContainer::class);
  144. }
  145. public function getTicketMessageContainer(): TicketMessageContainer
  146. {
  147. return $this->get(TicketMessageContainer::class);
  148. }
  149. public function getGroupUserContainer(): GroupUserContainer
  150. {
  151. return $this->get(GroupUserContainer::class);
  152. }
  153. public function getUserContainer(): UserContainer
  154. {
  155. return $this->get(UserContainer::class);
  156. }
  157. public function getSiteSettingContainer(): SiteSettingContainer
  158. {
  159. return $this->get(SiteSettingContainer::class);
  160. }
  161. }