src/Frontend/OpenSpaceBundle/Controller/DefaultController.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Frontend\OpenSpaceBundle\Controller;
  3. use App\AMZ\CoreBundle\Services\AMZS;
  4. use App\AMZ\InquiryBundle\Entity\Inquiry;
  5. use App\AMZ\InquiryBundle\Entity\Project;
  6. use App\AMZ\PostBundle\Entity\Post;
  7. use App\Frontend\OpenSpaceBundle\Services\OpenSpace;
  8. use App\Frontend\OpenSpaceBundle\Services\OpenSpaceService;
  9. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  10. use Symfony\Component\HttpFoundation\Request;
  11. use Symfony\Component\HttpFoundation\Response;
  12. class DefaultController extends AbstractController
  13. {
  14.     public function indexAction(OpenSpaceService $frontendService){
  15.         $sliders $frontendService->getSliderForHomepage();
  16.         $aboutUsSlider $frontendService->getBannerBySlug(OpenSpace::DEFAULT_HOMEPAGE_ABOUT_US);
  17.         $articleSlider $frontendService->getBannerBySlug(OpenSpace::DEFAULT_HOMEPAGE_ARTICLES);
  18.         $contactSlider $frontendService->getBannerBySlug(OpenSpace::DEFAULT_HOMEPAGE_CONTACT);
  19.         $partnerSlider $frontendService->getBannerBySlug(OpenSpace::DEFAULT_HOMEPAGE_PARTNER);
  20.         $homepageSection = array(
  21.             $aboutUsSlider,$articleSlider,$partnerSlider,$contactSlider
  22.         );
  23.         return $this->render('@FrontendOpenSpace/Default/index.html.twig',[ 'sliders' => $sliders,
  24.             'homepageSection' => $homepageSection,
  25.             'effects' => ['fadeIn''rollIn','bounceIn','flipInY']
  26.         ]);
  27.     }
  28.     public function aboutAction(OpenSpaceService $frontendService){
  29.         $pageSlug OpenSpace::PAGE_SERVICES_SLUG;
  30.         $page $frontendService->getPageBySlug($pageSlug);
  31. //        get service page
  32.         $services $frontendService->getCompanyService();
  33.         $testimonial $frontendService->getTestimonial();
  34.         $content1Slug OpenSpace::PAGE_SERVICE_CONTENT_SLUG_1;
  35.         $content1 $frontendService->getPageBySlug($content1Slug);
  36.         $content2Slug OpenSpace::PAGE_SERVICE_CONTENT_SLUG_2;
  37.         $content2 $frontendService->getPageBySlug($content2Slug);
  38.         $content3 $frontendService->getPageBySlug(OpenSpace::PAGE_SERVICE_CONTENT_SLUG_3);
  39.         return $this->render('@FrontendOpenSpace/About/index.html.twig',array('page'=>$page,'services'=>$services,'testimonial' => $testimonial,'content1'=>$content1,'content2'=>$content2,'content3'=>$content3));
  40.     }
  41.     public function staticAction(Request $request$slug){
  42.         $article $this->getDoctrine()->getRepository("AMZPostBundle:Post")
  43.             ->findOneBy(['slug' => $slug,'deleted' => AMZS::STATUS_NOT_DELETED ]);
  44.         return $this->render('@FrontendAbt/page/article-detail.html.twig',['article' => $article]);
  45.     }
  46.     public function contactAction(){
  47.         return $this->render('@FrontendAbt/page/contact.html.twig');
  48.     }
  49.     public function receiveInquiryAction(OpenSpaceService $frontendServiceRequest $request, \Swift_Mailer $mailer){
  50.         $data $request->request->all();
  51.         $arrayValid $frontendService->validateInquiryData($data);
  52. //        data is valid ~ empty($arrayValid) = true
  53.         if(empty($arrayValid)){
  54.             $entity = new Inquiry();
  55.             $entity->setName($data['name']);
  56.             $entity->setPhone($data['phone']);
  57.             $entity->setEmail($data['email']);
  58.             $post = new Post();
  59.             $post->setTitle($data['title']);
  60.             $post->setContent($data['content']);
  61.             $post->setType(AMZS::POST_TYPE_INQUIRY);
  62.             $entity->setPost($post);
  63.             $this->getDoctrine()->getManager()->persist($post);
  64.             $this->getDoctrine()->getManager()->persist($entity);
  65.             $this->getDoctrine()->getManager()->flush();
  66. //            sent mail
  67.             $message = (new \Swift_Message('lien-he-tu-website-abt'))
  68.                 ->setFrom('contact-form@amzsolution.com')
  69.                 ->setTo('lcghoang@gmail.com')
  70.                 ->setBody(
  71.                     "You have a new message from contact form."
  72.                 )
  73.             ;
  74.             $rs $mailer->send($message);
  75.             return new Response('sent-inquiry-success'$rs);
  76.         }
  77.     }
  78. }
  79. ?>