private function checkKey($key) { $user = $this->userRepository->findUserByKey($key); if ($user) { return false; } return true; }
/** * Checks if API-Key is valid * @param string $apiKey */ private function isKeyValid($apiKey) { $user = $this->userRepository->findUserByKey($apiKey); if (!$user) { throw new AccessDeniedHttpException('Your API key is not valid'); } return $user; }
/** * @param InputInterface $input * @param OutputInterface $output */ protected function execute(InputInterface $input, OutputInterface $output) { $table = new Table($output); $table->setHeaders(['ID', 'Username', 'API-Key'])->addRows($this->userRepository->findAll()); $table->render(); }