getClass(); $userId = $this->security->getUser()->getUserIdentifier(); $idnDomain = RDAPService::convertToIdn($uriVariables['ldhName']); $this->logger->info('User wants to update a domain name', [ 'username' => $userId, 'ldhName' => $idnDomain, ]); $request = $this->requestStack->getCurrentRequest(); /** @var ?Domain $domain */ $domain = $this->domainRepository->findOneBy(['ldhName' => $idnDomain]); // If the domain name exists in the database, recently updated and not important, we return the stored Domain if (null !== $domain && !$domain->getDeleted() && !$this->RDAPService->isToBeUpdated($domain, true, true) && ($request && !filter_var($request->get('forced', false), FILTER_VALIDATE_BOOLEAN)) ) { $this->logger->debug('It is not necessary to update the domain name', [ 'ldhName' => $idnDomain, 'updatedAt' => $domain->getUpdatedAt()->format(\DateTimeInterface::ATOM), ]); return $domain; } if (false === $this->kernel->isDebug() && true === $this->parameterBag->get('limited_features')) { $limiter = $this->rdapRequestsLimiter->create($userId); $limit = $limiter->consume(); if (!$limit->isAccepted()) { throw new TooManyRequestsHttpException($limit->getRetryAfter()->getTimestamp() - time()); } } $updatedAt = null === $domain ? new \DateTimeImmutable('now') : $domain->getUpdatedAt(); try { $domain = $this->RDAPService->registerDomain($idnDomain); } catch (DomainNotFoundException $exception) { if (!$fromWatchlist) { throw $exception; } $domain = $this->domainRepository->findOneBy(['ldhName' => $idnDomain]); if (null !== $domain) { return $domain; } $domain = (new Domain()) ->setLdhName($idnDomain) ->setTld($this->RDAPService->getTld($idnDomain)) ->setDelegationSigned(false) ->setDeleted(true); $this->em->persist($domain); $this->em->flush(); return $domain; } $randomizer = new Randomizer(); $watchlists = $randomizer->shuffleArray($domain->getWatchlists()->toArray()); /** @var Watchlist $watchlist */ foreach ($watchlists as $watchlist) { $this->bus->dispatch(new SendDomainEventNotif($watchlist->getToken(), $domain->getLdhName(), $updatedAt)); } return $domain; } }