Last active
December 25, 2022 20:05
-
-
Save ismail1432/27256d779a4151ee95dc4933e795fd73 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Controller; | |
use Symfony\Component\HttpFoundation\JsonResponse; | |
use Symfony\Component\HttpFoundation\Request; | |
use Symfony\Component\HttpFoundation\Response; | |
use Symfony\Component\Routing\Annotation\Route; | |
class UserAction | |
{ | |
/** | |
* @Route("/users", | |
* name="get", | |
* methods="GET", | |
* defaults={ | |
* "_validator": { | |
* "limit":"Positive" | |
* } | |
* }) | |
*/ | |
public function search(Request $request): Response | |
{ | |
$errors = $request->attributes->get('_errors'); | |
if ([] !== $errors) { | |
return new JsonResponse($this->formatError($errors), 400); | |
} | |
// boring stuff, fetch users... | |
return new JsonResponse($users, 201); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment