private function getClientCount(ClientRepository $clientRepo, Authorization $entity) { $counts = $clientRepo->getCountPerson($entity->getPerson(), $entity->getClient()->getId()); if (count($counts) > 0) { $count = $counts[0]['qty']; } else { $count = 0; } if (!is_int($count)) { $count = 0; } return $count; }
public function checkDeploy(GetResponseEvent $event) { if (null === $this->cache || $this->cache->contains(self::CHECK_DEPLOY_KEY)) { return; } $clients = $this->clientRepository->countClients(); $cities = $this->cityRepository->countCities(); $hasDefaultClient = $this->clientRepository->findOneByUid($this->defaultClientUid) instanceof Client; if ($clients <= 0 || $cities <= 0 || !$hasDefaultClient) { $this->cache->delete(self::CHECK_DEPLOY_KEY); throw new \RuntimeException('Make sure you did run the populate database command.'); } else { $this->cache->save(self::CHECK_DEPLOY_KEY, true); } }
public function onRegistrationCompleted(FilterUserResponseEvent $event) { $user = $event->getUser(); $auth = new Authorization(); $auth->setPerson($user); $auth->setClient($this->clientRepository->findOneBy(['uid' => $this->defaultClientUid])); $auth->setScope(explode(' ', $this->lcSupportedScopes)); $this->em->persist($auth); $this->em->flush(); $this->mailer->sendConfirmationEmailMessage($user); if (strlen($user->getPassword()) == 0) { // TODO: DEPRECATE NOTIFICATIONS // TODO: create an optional task offering users to set a password //$this->notificationsHelper->enforceEmptyPasswordNotification($user); } $this->registerRequestedScope->clearRequestedScope($event->getRequest()); }