Download src/Presentation/RequestHandlers/Admin/PayoutRequestHandler.php from pnacorp/AIKEEDO: direct link, hf CLI and curl.
- Browser
- Download file 1.58 kB
-
https://huggingface.co/pnacorp/AIKEEDO/resolve/main/src/Presentation/RequestHandlers/Admin/PayoutRequestHandler.php
- Command line
-
hf download hf://pnacorp/AIKEEDO/src/Presentation/RequestHandlers/Admin/PayoutRequestHandler.php
-
curl -L -o PayoutRequestHandler.php https://huggingface.co/pnacorp/AIKEEDO/resolve/main/src/Presentation/RequestHandlers/Admin/PayoutRequestHandler.php
1.58 kB
| declare(strict_types=1); | |
| namespace Presentation\RequestHandlers\Admin; | |
| use Affiliate\Application\Commands\ReadPayoutCommand; | |
| use Affiliate\Domain\Entities\PayoutEntity; | |
| use Affiliate\Domain\Exceptions\PayoutNotFoundException; | |
| use Easy\Http\Message\RequestMethod; | |
| use Easy\Router\Attributes\Route; | |
| use Presentation\Resources\Admin\Api\PayoutResource; | |
| 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 Shared\Infrastructure\CommandBus\Exception\NoHandlerFoundException; | |
| (path: '/payouts/[uuid:id]', method: RequestMethod::GET) | |
| class PayoutRequestHandler extends AbstractAdminViewRequestHandler implements | |
| RequestHandlerInterface | |
| { | |
| public function __construct( | |
| private Dispatcher $dispatcher | |
| ) {} | |
| /** | |
| * @throws NoHandlerFoundException | |
| */ | |
| public function handle(ServerRequestInterface $request): ResponseInterface | |
| { | |
| $id = $request->getAttribute('id'); | |
| $cmd = new ReadPayoutCommand($id); | |
| try { | |
| /** @var PayoutEntity */ | |
| $payout = $this->dispatcher->dispatch($cmd); | |
| } catch (PayoutNotFoundException) { | |
| return new RedirectResponse('/admin/payouts'); | |
| } | |
| return new ViewResponse( | |
| '/templates/admin/payout.twig', | |
| ['payout' => new PayoutResource($payout, ['affiliate', 'affiliate.user'])] | |
| ); | |
| } | |
| } | |