Viewing File: /usr/local/cpanel/whostmgr/docroot/cgi/ncssl/source/src/Service/User.php
<?php
namespace App\Service;
use App\Exception\UserException;
use App\Repository\UserRepository;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Exception\NotSupported;
class User
{
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly UserRepository $userRepository,
) {
}
/**
* @param string $ncLogin
* @param int $expectedStatus
*
* @return void
* @throws UserException
* @throws \Doctrine\ORM\Exception\ORMException
* @throws \Doctrine\ORM\OptimisticLockException
*/
public function setAutoRedirect(string $ncLogin, string $userName, int $expectedStatus): void
{
try {
$userEntity = $this->userRepository->findOneBy(['ncLogin' => $ncLogin, 'name' => $userName]);
} catch (NotSupported $e) {
throw new UserException('UserRepository not found');
}
if (!$userEntity) {
throw new UserException('User not found');
}
$userEntity->setAutoRedirect($expectedStatus);
$this->entityManager->flush();
}
}
Back to Directory
File Manager