<?php
namespace App\project\OfficeBrain\CustomBundle\CmsBundle\Controller;
// use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpFoundation\Request;
use App\project\OfficeBrain\CustomBundle\CmsBundle\Manager\Extended\CmsFlashMessageExtended;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* @author OfficeBrain 5051 <info@officebrain.com>
*
* Description : CMS controller class
*
* @Route("/{_locale}")
**/
class CmsFlashMessageController extends AbstractController
{
private $request;
private $session;
private $translator;
private $projectSetting;
private $recordsPerPage;
private $cmsFlashMessageManager;
private $responseArray;
public function __construct(CmsFlashMessageExtended $cmsFlashMessageManager, TranslatorInterface $translator) {
$this->cmsFlashMessageManager = $cmsFlashMessageManager;
$this->translator = $translator;
}
public function __destruct()
{
unset($this->request);
unset($this->session);
unset($this->translator);
unset($this->projectSetting);
unset($this->cmsFlashMessageManager);
unset($this->responseArray);
}
public function initAction(Request $request)
{
$this->request = $request;
$this->session = $this->request->getSession();
// $this->translator = $this->get('translator');
$this->projectSetting = $this->request->get('project_setting');
// $this->cmsFlashMessageManager = $this->get('office_brain_custom_cms_flash_message_manager'); // symfony 4
$this->responseArray = array();
}
/**
* * @author Employee Id: 5051
* Description : Get the page content and render page on fronend on home page
* *
* @Route("/flash-message", name="office_brain_custombundle_cmsbundle_cmsflash_flashmessage")
* @Template("project/OfficeBrain/CustomBundle/CmsBundle/CmsFlashMessage/flashMessage.html.twig")
*/
public function flashMessageAction(Request $request)
{
$this->initAction($request);
$this->responseArray['data'] = $this->cmsFlashMessageManager->getCmsFlashMessage();
if (!empty($this->responseArray['error']) && $this->responseArray['error'] == "MESSAGE_NOT_FOUND") {
//throw $this->createNotFoundException($this->translator->trans('cms.front.flash_message.page_not_found'));
$this->responseArray = "";
}
return $this->responseArray;
}
}