WIP: Symfony 6 project remake #2
|
@ -12,6 +12,9 @@ services:
|
||||||
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
|
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
|
||||||
bind:
|
bind:
|
||||||
# TODO: fix retrieval
|
# TODO: fix retrieval
|
||||||
|
# Point Tools
|
||||||
|
$appUserId: 435
|
||||||
|
$appUserLogin: 'point-tools'
|
||||||
# Telegram Bot API
|
# Telegram Bot API
|
||||||
$telegramToken: ''
|
$telegramToken: ''
|
||||||
$debugEnabled: '%kernel.debug%'
|
$debugEnabled: '%kernel.debug%'
|
||||||
|
|
|
@ -1,30 +1,22 @@
|
||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace src\PointToolsBundle\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use Doctrine\ORM\EntityManager;
|
use App\Form\UserSearchType;
|
||||||
use src\PointToolsBundle\Form\UserSearchType;
|
use App\Repository\{SubscriptionEventRepository, SubscriptionRepository, UserRepository};
|
||||||
use src\PointToolsBundle\Repository\SubscriptionRepository;
|
|
||||||
use src\PointToolsBundle\Repository\UserRepository;
|
|
||||||
use src\PointToolsBundle\Repository\{SubscriptionEventRepository};
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\Form\FormError;
|
use Symfony\Component\Form\FormError;
|
||||||
use Symfony\Component\HttpFoundation\{JsonResponse, Request, Response};
|
use Symfony\Component\HttpFoundation\{JsonResponse, Request, Response};
|
||||||
|
|
||||||
class MainController extends AbstractController
|
class MainController extends AbstractController
|
||||||
{
|
{
|
||||||
const AJAX_AUTOCOMPLETE_SIZE = 10;
|
private const AJAX_AUTOCOMPLETE_SIZE = 10;
|
||||||
|
|
||||||
/** @var int */
|
public function __construct(
|
||||||
private $appUserId;
|
private readonly int $appUserId,
|
||||||
|
private readonly string $appUserLogin,
|
||||||
/** @var string */
|
) {
|
||||||
private $appUserLogin;
|
|
||||||
|
|
||||||
public function __construct(int $appUserId, string $appUserLogin)
|
|
||||||
{
|
|
||||||
$this->appUserId = $appUserId;
|
|
||||||
$this->appUserLogin = $appUserLogin;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function indexAction(
|
public function indexAction(
|
||||||
|
@ -33,9 +25,6 @@ class MainController extends AbstractController
|
||||||
SubscriptionRepository $subscriptionRepository,
|
SubscriptionRepository $subscriptionRepository,
|
||||||
SubscriptionEventRepository $subscriptionEventRepository
|
SubscriptionEventRepository $subscriptionEventRepository
|
||||||
): Response {
|
): Response {
|
||||||
/** @var EntityManager $em */
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
|
||||||
|
|
||||||
$form = $this->createForm(
|
$form = $this->createForm(
|
||||||
UserSearchType::class,
|
UserSearchType::class,
|
||||||
null,
|
null,
|
||||||
|
@ -66,17 +55,9 @@ class MainController extends AbstractController
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Returns user search autocomplete data in JSON */
|
||||||
* Returns user search autocomplete data in JSON
|
public function searchUserAjaxAction(string $login, UserRepository $userRepository): JsonResponse
|
||||||
*
|
|
||||||
* @param string $login
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
*/
|
|
||||||
public function searchUserAjaxAction(string $login, UserRepository $userRepository): Response
|
|
||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
|
|
||||||
foreach ($userRepository->findUsersLikeLogin($login, self::AJAX_AUTOCOMPLETE_SIZE) as $user) {
|
foreach ($userRepository->findUsersLikeLogin($login, self::AJAX_AUTOCOMPLETE_SIZE) as $user) {
|
Loading…
Reference in a new issue