src/Controller/MainController.php line 12

  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Company;
  4. use App\Entity\CompanyComment;
  5. use App\Repository\MetaRepository;
  6. use Doctrine\ORM\EntityManagerInterface;
  7. use PhpParser\Comment;
  8. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  9. use Symfony\Component\HttpFoundation\Request;
  10. use Symfony\Component\Routing\Annotation\Route;
  11. class MainController extends AbstractController
  12. {
  13.     #[Route('/'name'page_home1'requirements: ['_locale' => 'en|ru|hy'], defaults: ['_locale' => 'ru'])]
  14.     public function index1(MetaRepository $metaRepository)
  15.     {
  16.         return $this->render('@web/page/index.html.twig');
  17.     }
  18.     #[Route('/{_locale}'name'page_home'requirements: ['_locale' => 'en|ru|hy'], defaults: ['_locale' => 'ru'])]
  19.     public function index(MetaRepository $metaRepository)
  20.     {
  21.         return $this->render('@web/page/index.html.twig');
  22.     }
  23.     #[Route('/test'name'page_test'requirements: ['_locale' => 'en|ru|hy'], defaults: ['_locale' => 'ru'])]
  24.     public function page_test()
  25.     {
  26.         return $this->render('@email/first_template.html.twig');
  27.     }
  28.     #[Route('/page_comment'name'page_comment')]
  29.     public function companyComment(Request $requestEntityManagerInterface $entityManager)
  30.     {
  31.         $comment = new CompanyComment();
  32.         $companyId $request->get('companyId');
  33.         $user $this->getUser();
  34.         $date \DateTime::createFromFormat('Y-m-d\TH:i'$request->get('task-date'));
  35.         $company $entityManager->getRepository(Company::class)->find($companyId);
  36.         if ($request->get('parentId')){
  37.             $oldComment $entityManager->getRepository(CompanyComment::class)->find($request->get('parentId'));
  38.             $comment->setParent($oldComment);
  39.         }
  40.         $comment->setCompany($company);
  41.         $comment->setUser($user);
  42.         $comment->setActivity($request->get('activity'));
  43.         $comment->setComment($request->get('message'));
  44.         $comment->setNextStepDate($date);
  45.         $comment->setNextStep($request->get('task'));
  46.         $comment->setCreatedAt(new \DateTime());
  47.         $entityManager->persist($comment);
  48.         $entityManager->flush();
  49.         return $this->redirect($request->headers->get('referer'));
  50.     }
  51. }