diff --git a/webapp/php/src/AbstractHandler.php b/webapp/php/src/AbstractHandler.php new file mode 100644 index 000000000..eede44c9f --- /dev/null +++ b/webapp/php/src/AbstractHandler.php @@ -0,0 +1,19 @@ +getBody()->write(json_encode($data)); + + return $response->withHeader('Content-Type', 'application/json') + ->withStatus($status); + } +} diff --git a/webapp/php/src/InitializeHandler.php b/webapp/php/src/InitializeHandler.php index 02530ffea..f6b8b385f 100644 --- a/webapp/php/src/InitializeHandler.php +++ b/webapp/php/src/InitializeHandler.php @@ -8,7 +8,7 @@ /** * FIXME: ポータルと足並み揃えて修正 */ -class InitializeHandler +class InitializeHandler extends AbstractHandler { public function __invoke(Request $request, Response $response): Response { diff --git a/webapp/php/src/Livecomment/Handler.php b/webapp/php/src/Livecomment/Handler.php index 2e83ea511..0b062988b 100644 --- a/webapp/php/src/Livecomment/Handler.php +++ b/webapp/php/src/Livecomment/Handler.php @@ -4,10 +4,11 @@ namespace IsuPipe\Livecomment; +use IsuPipe\AbstractHandler; use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; -class Handler +class Handler extends AbstractHandler { public function getLivecommentsHandler(Request $request, Response $response): Response { diff --git a/webapp/php/src/Livestream/Handler.php b/webapp/php/src/Livestream/Handler.php index 2d161348f..3e0150ed5 100644 --- a/webapp/php/src/Livestream/Handler.php +++ b/webapp/php/src/Livestream/Handler.php @@ -4,10 +4,11 @@ namespace IsuPipe\Livestream; +use IsuPipe\AbstractHandler; use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; -class Handler +class Handler extends AbstractHandler { public function reserveLivestreamHandler(Request $request, Response $response): Response { diff --git a/webapp/php/src/Payment/Handler.php b/webapp/php/src/Payment/Handler.php index dfddfe5d0..514bd4783 100644 --- a/webapp/php/src/Payment/Handler.php +++ b/webapp/php/src/Payment/Handler.php @@ -4,10 +4,11 @@ namespace IsuPipe\Payment; +use IsuPipe\AbstractHandler; use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; -class Handler +class Handler extends AbstractHandler { public function getPaymentResult(Request $request, Response $response): Response { diff --git a/webapp/php/src/Reaction/Handler.php b/webapp/php/src/Reaction/Handler.php index c521beaae..7d08365cc 100644 --- a/webapp/php/src/Reaction/Handler.php +++ b/webapp/php/src/Reaction/Handler.php @@ -4,10 +4,11 @@ namespace IsuPipe\Reaction; +use IsuPipe\AbstractHandler; use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; -class Handler +class Handler extends AbstractHandler { public function getReactionsHandler(Request $request, Response $response): Response { diff --git a/webapp/php/src/Stats/Handler.php b/webapp/php/src/Stats/Handler.php index a04255974..568006899 100644 --- a/webapp/php/src/Stats/Handler.php +++ b/webapp/php/src/Stats/Handler.php @@ -4,10 +4,11 @@ namespace IsuPipe\Stats; +use IsuPipe\AbstractHandler; use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; -class Handler +class Handler extends AbstractHandler { public function getUserStatisticsHandler(Request $request, Response $response): Response { diff --git a/webapp/php/src/Top/Handler.php b/webapp/php/src/Top/Handler.php index 6313e15b7..36aee690b 100644 --- a/webapp/php/src/Top/Handler.php +++ b/webapp/php/src/Top/Handler.php @@ -4,11 +4,18 @@ namespace IsuPipe\Top; +use IsuPipe\AbstractHandler; +use PDO; use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; -class Handler +class Handler extends AbstractHandler { + public function __construct( + private PDO $db, + ) { + } + public function getTagHandler(Request $request, Response $response): Response { // TODO: 実装 diff --git a/webapp/php/src/User/Handler.php b/webapp/php/src/User/Handler.php index 85a550ae1..460e1830e 100644 --- a/webapp/php/src/User/Handler.php +++ b/webapp/php/src/User/Handler.php @@ -4,10 +4,11 @@ namespace IsuPipe\User; +use IsuPipe\AbstractHandler; use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; -class Handler +class Handler extends AbstractHandler { public function getIconHandler(Request $request, Response $response): Response {