您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

AbstractController.php 6.5KB

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