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 findByStateId($id) { $reviewed = City::REVIEWED_OK; return $this->repository->createQueryBuilder('c')->join('c.state', 's')->where('s.id = :id')->andWhere('c.reviewed = :reviewed')->orderBy('c.name')->setParameters(compact('id', 'reviewed'))->getQuery()->getResult(); }