createApi improvements
This commit is contained in:
parent
3cb5eaa4d9
commit
27be2c79dd
@ -110,7 +110,7 @@ return [
|
|||||||
{$apiHandlerName}::class => AutoWiringFactory::class,
|
{$apiHandlerName}::class => AutoWiringFactory::class,
|
||||||
|
|
||||||
// Response Formatter
|
// Response Formatter
|
||||||
{$$apiResponseFormatterName}::class => AutoWiringFactory::class,
|
{$apiResponseFormatterName}::class => AutoWiringFactory::class,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
";
|
";
|
||||||
|
|||||||
16
src/ApiDomain/External/TagList/config/routes.php
vendored
Normal file
16
src/ApiDomain/External/TagList/config/routes.php
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use MyTube\API\External\TagList\Handler\ReadListHandler;
|
||||||
|
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'name' => 'TODO.TODO',
|
||||||
|
'path' => '/api/TODO/TODO[/]',
|
||||||
|
'allowed_methods' => ['POST'],
|
||||||
|
'middleware' => [
|
||||||
|
ReadListHandler::class,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
17
src/ApiDomain/External/TagList/config/service_manager.php
vendored
Normal file
17
src/ApiDomain/External/TagList/config/service_manager.php
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use MyTube\API\External\TagList\Handler\ReadListHandler;
|
||||||
|
use MyTube\API\External\TagList\ResponseFormatter\ReadListResponseFormatter;
|
||||||
|
use Reinfi\DependencyInjection\Factory\AutoWiringFactory;
|
||||||
|
|
||||||
|
return [
|
||||||
|
'factories' => [
|
||||||
|
// Handler
|
||||||
|
ReadListHandler::class => AutoWiringFactory::class,
|
||||||
|
|
||||||
|
// Response Formatter
|
||||||
|
::class => AutoWiringFactory::class,
|
||||||
|
],
|
||||||
|
];
|
||||||
16
src/ApiDomain/External/TagList/src/ConfigProvider.php
vendored
Normal file
16
src/ApiDomain/External/TagList/src/ConfigProvider.php
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MyTube\API\{External}\{TagList};
|
||||||
|
|
||||||
|
class ConfigProvider
|
||||||
|
{
|
||||||
|
public function __invoke(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'dependencies' => require __DIR__ . './../config/service_manager.php',
|
||||||
|
'routes' => require __DIR__ . '/./../config/routes.php',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
38
src/ApiDomain/External/TagList/src/Handler/ReadListHandler.php
vendored
Normal file
38
src/ApiDomain/External/TagList/src/Handler/ReadListHandler.php
vendored
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MyTube\API\External\TagList\Handler;
|
||||||
|
|
||||||
|
use MyTube\Handling\TagList\Handler\Query\ReadList\ReadListQueryHandler;
|
||||||
|
use MyTube\Handling\TagList\Handler\Query\ReadList\ReadListQueryBuilder;
|
||||||
|
use MyTube\API\External\TagList\ResponseFormatter\ReadListResponseFormatter;
|
||||||
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
use Psr\Http\Server\RequestHandlerInterface;
|
||||||
|
use MyTube\Infrastructure\Response\SuccessResponse;
|
||||||
|
|
||||||
|
class ReadListHandler implements RequestHandlerInterface
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private readonly ReadListQueryHandler $readListQueryHandler,
|
||||||
|
private readonly ReadListQueryBuilder $readListQueryBuilder,
|
||||||
|
private readonly ReadListResponseFormatter $responseFormatter,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handle(ServerRequestInterface $request): ResponseInterface
|
||||||
|
{
|
||||||
|
$data = json_decode(
|
||||||
|
$request->getBody()->getContents(),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
$readListQuery = $this->readListQueryBuilder->build(
|
||||||
|
$data
|
||||||
|
);
|
||||||
|
$result = $this->readListQueryHandler->execute($readListQuery);
|
||||||
|
|
||||||
|
return new SuccessResponse($this->responseFormatter->format($result));
|
||||||
|
}
|
||||||
|
}
|
||||||
15
src/ApiDomain/External/TagList/src/ResponseFormatter/ReadListResponseFormatter.php
vendored
Normal file
15
src/ApiDomain/External/TagList/src/ResponseFormatter/ReadListResponseFormatter.php
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MyTube\API\External\TagList\ResponseFormatter;
|
||||||
|
|
||||||
|
use MyTube\Handling\TagList\Handler\Query\ReadList\ReadListQueryResult;
|
||||||
|
|
||||||
|
class ReadListResponseFormatter
|
||||||
|
{
|
||||||
|
public function format(ReadListQueryResult $readListQueryResult): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
17
src/HandlingDomain/TagList/config/service_manager.php
Normal file
17
src/HandlingDomain/TagList/config/service_manager.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use MyTube\Handling\TagList\Handler\Query\ReadList\ReadListQueryHandler;
|
||||||
|
use MyTube\Handling\TagList\Handler\Query\ReadList\ReadListQueryBuilder;
|
||||||
|
use Reinfi\DependencyInjection\Factory\AutoWiringFactory;
|
||||||
|
use Reinfi\DependencyInjection\Factory\InjectionFactory;
|
||||||
|
|
||||||
|
return [
|
||||||
|
'factories' => [
|
||||||
|
/// CQRS
|
||||||
|
// ReadList
|
||||||
|
ReadListQueryBuilder::class => AutoWiringFactory::class,
|
||||||
|
ReadListQueryHandler::class => AutoWiringFactory::class,
|
||||||
|
],
|
||||||
|
];
|
||||||
15
src/HandlingDomain/TagList/src/ConfigProvider.php
Normal file
15
src/HandlingDomain/TagList/src/ConfigProvider.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MyTube\Handling\{MyTube\Handling\TagList\Handler\Query\ReadList};
|
||||||
|
|
||||||
|
class ConfigProvider
|
||||||
|
{
|
||||||
|
public function __invoke(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'dependencies' => require __DIR__ . './../config/service_manager.php',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MyTube\Handling\TagList\Handler\Query\ReadList;
|
||||||
|
|
||||||
|
class ReadListQuery
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
#TODO
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MyTube\Handling\TagList\Handler\Query\ReadList;
|
||||||
|
|
||||||
|
class ReadListQueryBuilder
|
||||||
|
{
|
||||||
|
public function build(
|
||||||
|
#TODO
|
||||||
|
): ReadListQuery {
|
||||||
|
return new ReadListQuery(
|
||||||
|
#TODO
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MyTube\Handling\TagList\Handler\Query\ReadList;
|
||||||
|
|
||||||
|
class ReadListQueryHandler
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
#TODO
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execute(ReadListQuery $readListQuery): ReadListQueryResult
|
||||||
|
{
|
||||||
|
return new ReadListQueryResult();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace MyTube\Handling\TagList\Handler\Query\ReadList;
|
||||||
|
|
||||||
|
class ReadListQueryResult
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
#TODO
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user