Download src/Presentation/RequestHandlers/Admin/AssistantRequestHandler.php from pnacorp/AIKEEDO: direct link, hf CLI and curl.
- Browser
- Download file 1.53 kB
-
https://huggingface.co/pnacorp/AIKEEDO/resolve/main/src/Presentation/RequestHandlers/Admin/AssistantRequestHandler.php
- Command line
-
hf download hf://pnacorp/AIKEEDO/src/Presentation/RequestHandlers/Admin/AssistantRequestHandler.php
-
curl -L -o AssistantRequestHandler.php https://huggingface.co/pnacorp/AIKEEDO/resolve/main/src/Presentation/RequestHandlers/Admin/AssistantRequestHandler.php
1.53 kB
| declare(strict_types=1); | |
| namespace Presentation\RequestHandlers\Admin; | |
| use Assistant\Application\Commands\ReadAssistantCommand; | |
| use Easy\Http\Message\RequestMethod; | |
| use Easy\Router\Attributes\Route; | |
| use Presentation\Resources\Admin\Api\AssistantResource; | |
| use Presentation\Response\RedirectResponse; | |
| use Presentation\Response\ViewResponse; | |
| use Psr\Http\Message\ServerRequestInterface; | |
| use Psr\Http\Message\ResponseInterface; | |
| use Psr\Http\Server\RequestHandlerInterface; | |
| use Shared\Infrastructure\CommandBus\Dispatcher; | |
| use User\Domain\Exceptions\UserNotFoundException; | |
| (path: '/assistants/[uuid:id]', method: RequestMethod::GET) | |
| (path: '/assistants/new', method: RequestMethod::GET) | |
| class AssistantRequestHandler extends AbstractAdminViewRequestHandler implements | |
| RequestHandlerInterface | |
| { | |
| public function __construct( | |
| private Dispatcher $dispatcher | |
| ) { | |
| } | |
| public function handle(ServerRequestInterface $request): ResponseInterface | |
| { | |
| $id = $request->getAttribute('id'); | |
| $data = []; | |
| if ($id) { | |
| $cmd = new ReadAssistantCommand($id); | |
| try { | |
| $assistant = $this->dispatcher->dispatch($cmd); | |
| } catch (UserNotFoundException $th) { | |
| return new RedirectResponse('/admin/users'); | |
| } | |
| $data['assistant'] = new AssistantResource($assistant); | |
| } | |
| return new ViewResponse( | |
| '/templates/admin/assistant.twig', | |
| $data | |
| ); | |
| } | |
| } | |