src/Controller/TestController.php line 21

  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\User;
  4. use App\Service\RegistrationService;
  5. use Doctrine\ORM\EntityManagerInterface;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  9. class TestController extends AbstractController
  10. {
  11.   private $jsonConst = ['json_encode_options' => JSON_UNESCAPED_UNICODE JSON_PRETTY_PRINT JSON_UNESCAPED_SLASHES JSON_HEX_QUOT'groups' => 'api_index'];
  12.   public function __construct(
  13.     private EntityManagerInterface $em,
  14.   ) {}
  15.   #[Route('/'name'frontpage')]
  16.   public function index(): Response
  17.   {
  18.     return $this->redirectToRoute('admin_dashboard');
  19.   }
  20.   #[Route('/test'name'test')]
  21.   public function test(): Response
  22.   {
  23.     return $this->render('test/index.html.twig', [
  24.     ]);
  25.   }
  26.   #[Route('/api/who'name'who')]
  27.   public function who(): Response
  28.   {
  29.     return $this->json($this->getUser(), 200, [], $this->jsonConst);
  30.   }
  31.   #[Route('/reg'name'reg_admin')]
  32.   public function reg_admin(RegistrationService $registrationService): Response
  33.   {
  34.     $user = new User();
  35.     $user->setEmail('dev@omedia.su');
  36.     $user $registrationService->regSimple($user'1234');
  37.     dd($user);
  38.   }
  39. }