<?php
namespace Uniski\ResourceBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
/**
* Base Controller with helper functions
* Migrado a AbstractController para Symfony 4.4
* Se mantiene acceso al container para retrocompatibilidad con $this->get()
*/
class BaseController extends AbstractController
{
/**
* Permite acceso a servicios del container por retrocompatibilidad.
* Los controladores hijos usan $this->get('servicio') extensivamente.
*/
public static function getSubscribedServices(): array
{
return array_merge(parent::getSubscribedServices(), [
'doctrine.orm.entity_manager' => '?'.EntityManagerInterface::class,
'knp_paginator' => '?Knp\Component\Pager\PaginatorInterface',
'app.search_manager' => '?Uniski\CommerceBundle\Service\SearchManager',
'app.product_service' => '?Uniski\CommerceBundle\Service\ProductService',
'app.product_price_service' => '?Uniski\CommerceBundle\Service\ProductPriceService',
'app.hotel_service' => '?Uniski\CommerceBundle\Service\HotelService',
'app.booking_manager' => '?Uniski\CommerceBundle\Service\BookingManager',
'app.payment_manager' => '?Uniski\CommerceBundle\Service\PaymentManager',
'app.booking_document_service' => '?Uniski\CommerceBundle\Service\BookingDocumentService',
'app.notification_manager' => '?Uniski\UserBundle\Service\NotificationManager',
'app.config_manager' => '?Uniski\ConfigBundle\Service\ConfigManager',
'app.category_manager' => '?Uniski\ConfigBundle\Service\CategoryManager',
'app.user_manager' => '?Uniski\UserBundle\Service\UserManager',
'app.subscription_manager' => '?Uniski\CMSBundle\Service\SubscriptionManager',
'app.offer_manager' => '?Uniski\CMSBundle\Service\OfferManager',
'app.webform_manager' => '?Uniski\CMSBundle\Service\WebFormManager',
'app.sort_manager' => '?Uniski\CommerceBundle\Service\SortManager',
'app.export_service' => '?Uniski\CommerceBundle\Service\ExportService',
'app.extra_price_service' => '?Uniski\CommerceBundle\Service\ExtraPriceService',
'app.search_product_service' => '?Uniski\CommerceBundle\Service\SearchProductService',
'app.room_stock_manager' => '?Uniski\ResourceBundle\Service\RoomStockManager',
'app.hotel_room_service' => '?Uniski\ResourceBundle\Service\HotelRoomService',
'app.booking.api' => '?Uniski\HotelBedsBundle\Booking\Infraestructure\API\HotelBedsBookingAPI',
'app.booking.service' => '?Uniski\HotelBedsBundle\Booking\DomainModel\BookingService',
'app.booking_price.service' => '?Uniski\HotelBedsBundle\Booking\DomainModel\BookingPriceService',
'app.hotel_import.service' => '?Uniski\HotelBedsBundle\Hotel\DomainModel\HotelImportService',
'app.uniskiprestige_service' => '?Uniski\PrestigeBundle\Service\UniskiPrestigeService',
'app.uniskiprestige_rest_service' => '?Uniski\PrestigeBundle\Service\UniskiPrestigeRestService',
'app.uniskiprestige.booking.api' => '?Uniski\PrestigeBundle\Infraestructure\PrestigeBookingAPI',
'app.uniskitravelgate.booking.api' => '?Uniski\TravelGateBundle\Booking\Infraestructure\API\TravelGateBookingAPI',
// 'phpexcel' => '?Liuggio\ExcelBundle\Factory', // PENDIENTE: migrar a PhpSpreadsheet
'logger' => '?'.LoggerInterface::class,
'request_stack' => '?Symfony\Component\HttpFoundation\RequestStack',
'event_dispatcher' => '?Symfony\Component\EventDispatcher\EventDispatcherInterface',
'router' => '?Symfony\Component\Routing\RouterInterface',
'security.authentication.guard_handler' => '?Symfony\Component\Security\Guard\GuardAuthenticatorHandler',
'app.security.login_form_authenticator' => '?Uniski\UserBundle\Security\LoginFormAuthenticator',
'session' => '?Symfony\Component\HttpFoundation\Session\SessionInterface',
'templating' => '?Symfony\Component\Templating\EngineInterface',
]);
}
public function getRepository($entity)
{
return $this->get('doctrine.orm.entity_manager')->getRepository($entity);
}
public function getEntityManager()
{
return $this->get('doctrine.orm.entity_manager');
}
public function removeFlash()
{
$this->get('session')->getFlashBag()->clear();
}
}