Skip to content

Commit 1115345

Browse files
dinamicdkarlovi
authored andcommitted
~ refactoring of AuthorizeController::getClient() to improve readability and make the code easier to follow and understand
1 parent d9b75de commit 1115345

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

Controller/AuthorizeController.php

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -249,25 +249,23 @@ protected function getRedirectionUrl(UserInterface $user)
249249
*/
250250
protected function getClient()
251251
{
252-
if (null === $this->client) {
253-
$request = $this->getCurrentRequest();
252+
if (null !== $this->client) {
253+
return $this->client;
254+
}
254255

255-
$client = null;
256-
if (null !== $request) {
257-
if (null === $clientId = $request->get('client_id')) {
258-
$form = $this->authorizeForm;
259-
$formData = $request->get($form->getName(), array());
260-
$clientId = isset($formData['client_id']) ? $formData['client_id'] : null;
261-
}
256+
if (null === $request = $this->getCurrentRequest()) {
257+
throw new NotFoundHttpException('Client not found.');
258+
}
262259

263-
$client = $this->clientManager->findClientByPublicId($clientId);
264-
}
260+
if (null === $clientId = $request->get('client_id')) {
261+
$formData = $request->get($this->authorizeForm->getName(), []);
262+
$clientId = $formData['client_id'] ?? null;
263+
}
265264

266-
if (null === $client) {
267-
throw new NotFoundHttpException('Client not found.');
268-
}
265+
$this->client = $this->clientManager->findClientByPublicId($clientId);
269266

270-
$this->client = $client;
267+
if (null === $this->client) {
268+
throw new NotFoundHttpException('Client not found.');
271269
}
272270

273271
return $this->client;

0 commit comments

Comments
 (0)