src/project/OfficeBrain/CustomBundle/CmsBundle/Controller/CmsFlashMessageController.php line 65

Open in your IDE?
  1. <?php
  2. namespace App\project\OfficeBrain\CustomBundle\CmsBundle\Controller;
  3. // use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  6. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  7. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
  8. use Symfony\Component\HttpFoundation\JsonResponse;
  9. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  10. use Symfony\Component\HttpFoundation\Request;
  11. use App\project\OfficeBrain\CustomBundle\CmsBundle\Manager\Extended\CmsFlashMessageExtended;
  12. use Symfony\Contracts\Translation\TranslatorInterface;
  13. /**
  14.  * @author OfficeBrain 5051 <info@officebrain.com>
  15.  *
  16.  * Description : CMS controller class
  17.  *
  18.  * @Route("/{_locale}")
  19.  **/
  20. class CmsFlashMessageController extends AbstractController
  21. {
  22.     private $request;
  23.     private $session;
  24.     private $translator;
  25.     private $projectSetting;
  26.     private $recordsPerPage;
  27.     private $cmsFlashMessageManager;
  28.     private $responseArray;
  29.     public function __construct(CmsFlashMessageExtended $cmsFlashMessageManagerTranslatorInterface $translator) {
  30.         $this->cmsFlashMessageManager $cmsFlashMessageManager;
  31.         $this->translator $translator;
  32.     }
  33.     public function __destruct()
  34.     {
  35.         unset($this->request);
  36.         unset($this->session);
  37.         unset($this->translator);
  38.         unset($this->projectSetting);
  39.         unset($this->cmsFlashMessageManager);
  40.         unset($this->responseArray);
  41.     }
  42.     public function initAction(Request $request)
  43.     {
  44.         $this->request $request;
  45.         $this->session $this->request->getSession();
  46.         // $this->translator = $this->get('translator');
  47.         $this->projectSetting $this->request->get('project_setting');
  48.         // $this->cmsFlashMessageManager = $this->get('office_brain_custom_cms_flash_message_manager'); // symfony 4
  49.         $this->responseArray = array();
  50.     }
  51.     /**
  52.      * * @author Employee Id: 5051
  53.      * Description : Get the page content and render page on fronend on home page
  54.      *      *
  55.      * @Route("/flash-message", name="office_brain_custombundle_cmsbundle_cmsflash_flashmessage")
  56.      * @Template("project/OfficeBrain/CustomBundle/CmsBundle/CmsFlashMessage/flashMessage.html.twig")
  57.      */
  58.     public function flashMessageAction(Request $request)
  59.     {
  60.         $this->initAction($request);
  61.         $this->responseArray['data'] = $this->cmsFlashMessageManager->getCmsFlashMessage();
  62.         if (!empty($this->responseArray['error']) && $this->responseArray['error'] == "MESSAGE_NOT_FOUND") {
  63.             //throw $this->createNotFoundException($this->translator->trans('cms.front.flash_message.page_not_found'));
  64.             $this->responseArray "";
  65.         }
  66.         return $this->responseArray;
  67.     }
  68. }