src/Uniski/ResourceBundle/Controller/BaseController.php line 67

Open in your IDE?
  1. <?php
  2. namespace Uniski\ResourceBundle\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Doctrine\ORM\EntityManagerInterface;
  5. use Psr\Log\LoggerInterface;
  6. /**
  7. * Base Controller with helper functions
  8. * Migrado a AbstractController para Symfony 4.4
  9. * Se mantiene acceso al container para retrocompatibilidad con $this->get()
  10. */
  11. class BaseController extends AbstractController
  12. {
  13.     /**
  14.      * Permite acceso a servicios del container por retrocompatibilidad.
  15.      * Los controladores hijos usan $this->get('servicio') extensivamente.
  16.      */
  17.     public static function getSubscribedServices(): array
  18.     {
  19.         return array_merge(parent::getSubscribedServices(), [
  20.             'doctrine.orm.entity_manager' => '?'.EntityManagerInterface::class,
  21.             'knp_paginator' => '?Knp\Component\Pager\PaginatorInterface',
  22.             'app.search_manager' => '?Uniski\CommerceBundle\Service\SearchManager',
  23.             'app.product_service' => '?Uniski\CommerceBundle\Service\ProductService',
  24.             'app.product_price_service' => '?Uniski\CommerceBundle\Service\ProductPriceService',
  25.             'app.hotel_service' => '?Uniski\CommerceBundle\Service\HotelService',
  26.             'app.booking_manager' => '?Uniski\CommerceBundle\Service\BookingManager',
  27.             'app.payment_manager' => '?Uniski\CommerceBundle\Service\PaymentManager',
  28.             'app.booking_document_service' => '?Uniski\CommerceBundle\Service\BookingDocumentService',
  29.             'app.notification_manager' => '?Uniski\UserBundle\Service\NotificationManager',
  30.             'app.config_manager' => '?Uniski\ConfigBundle\Service\ConfigManager',
  31.             'app.category_manager' => '?Uniski\ConfigBundle\Service\CategoryManager',
  32.             'app.user_manager' => '?Uniski\UserBundle\Service\UserManager',
  33.             'app.subscription_manager' => '?Uniski\CMSBundle\Service\SubscriptionManager',
  34.             'app.offer_manager' => '?Uniski\CMSBundle\Service\OfferManager',
  35.             'app.webform_manager' => '?Uniski\CMSBundle\Service\WebFormManager',
  36.             'app.sort_manager' => '?Uniski\CommerceBundle\Service\SortManager',
  37.             'app.export_service' => '?Uniski\CommerceBundle\Service\ExportService',
  38.             'app.extra_price_service' => '?Uniski\CommerceBundle\Service\ExtraPriceService',
  39.             'app.search_product_service' => '?Uniski\CommerceBundle\Service\SearchProductService',
  40.             'app.room_stock_manager' => '?Uniski\ResourceBundle\Service\RoomStockManager',
  41.             'app.hotel_room_service' => '?Uniski\ResourceBundle\Service\HotelRoomService',
  42.             'app.booking.api' => '?Uniski\HotelBedsBundle\Booking\Infraestructure\API\HotelBedsBookingAPI',
  43.             'app.booking.service' => '?Uniski\HotelBedsBundle\Booking\DomainModel\BookingService',
  44.             'app.booking_price.service' => '?Uniski\HotelBedsBundle\Booking\DomainModel\BookingPriceService',
  45.             'app.hotel_import.service' => '?Uniski\HotelBedsBundle\Hotel\DomainModel\HotelImportService',
  46.             'app.uniskiprestige_service' => '?Uniski\PrestigeBundle\Service\UniskiPrestigeService',
  47.             'app.uniskiprestige_rest_service' => '?Uniski\PrestigeBundle\Service\UniskiPrestigeRestService',
  48.             'app.uniskiprestige.booking.api' => '?Uniski\PrestigeBundle\Infraestructure\PrestigeBookingAPI',
  49.             'app.uniskitravelgate.booking.api' => '?Uniski\TravelGateBundle\Booking\Infraestructure\API\TravelGateBookingAPI',
  50.             // 'phpexcel' => '?Liuggio\ExcelBundle\Factory', // PENDIENTE: migrar a PhpSpreadsheet
  51.             'logger' => '?'.LoggerInterface::class,
  52.             'request_stack' => '?Symfony\Component\HttpFoundation\RequestStack',
  53.             'event_dispatcher' => '?Symfony\Component\EventDispatcher\EventDispatcherInterface',
  54.             'router' => '?Symfony\Component\Routing\RouterInterface',
  55.             'security.authentication.guard_handler' => '?Symfony\Component\Security\Guard\GuardAuthenticatorHandler',
  56.             'app.security.login_form_authenticator' => '?Uniski\UserBundle\Security\LoginFormAuthenticator',
  57.             'session' => '?Symfony\Component\HttpFoundation\Session\SessionInterface',
  58.             'templating' => '?Symfony\Component\Templating\EngineInterface',
  59.         ]);
  60.     }
  61.     public function getRepository($entity)
  62.     {
  63.         return $this->get('doctrine.orm.entity_manager')->getRepository($entity);
  64.     }
  65.     public function getEntityManager()
  66.     {
  67.         return $this->get('doctrine.orm.entity_manager');
  68.     }
  69.     public function removeFlash()
  70.     {
  71.         $this->get('session')->getFlashBag()->clear();
  72.     }
  73. }