This repository has been archived by the owner on Jul 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d13504e
commit 907c333
Showing
22 changed files
with
569 additions
and
60 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
doc/ServiceFactory/AcceptAndContentTypeMiddlewareFactory.md
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# AcceptAndContentTypeMiddlewareFactory | ||
|
||
## without name (default) | ||
|
||
```php | ||
<?php | ||
|
||
use Chubbyphp\ApiHttp\Container\AcceptAndContentTypeMiddlewareFactory; | ||
use Psr\Container\ContainerInterface; | ||
|
||
/** @var ContainerInterface $container */ | ||
$container = ...; | ||
|
||
$factory = new AcceptAndContentTypeMiddlewareFactory(); | ||
|
||
$acceptAndContentTypeMiddleware = $factory($container); | ||
``` | ||
|
||
## with name `default` | ||
|
||
```php | ||
<?php | ||
|
||
use Chubbyphp\ApiHttp\Container\AcceptAndContentTypeMiddlewareFactory; | ||
use Psr\Container\ContainerInterface; | ||
|
||
/** @var ContainerInterface $container */ | ||
$container = ...; | ||
|
||
$factory = [AcceptAndContentTypeMiddlewareFactory::class, 'default']; | ||
|
||
$acceptAndContentTypeMiddleware = $factory($container); | ||
``` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# ApiExceptionMiddlewareFactory | ||
|
||
## without name (default) | ||
|
||
```php | ||
<?php | ||
|
||
use Chubbyphp\ApiHttp\ServiceFactory\ApiExceptionMiddlewareFactory; | ||
use Psr\Container\ContainerInterface; | ||
|
||
/** @var ContainerInterface $container */ | ||
$container = ...; | ||
|
||
$factory = new ApiExceptionMiddlewareFactory(); | ||
|
||
$apiExceptionMiddleware = $factory($container); | ||
``` | ||
|
||
## with name `default` | ||
|
||
```php | ||
<?php | ||
|
||
use Chubbyphp\ApiHttp\ServiceFactory\ApiExceptionMiddlewareFactory; | ||
use Psr\Container\ContainerInterface; | ||
|
||
/** @var ContainerInterface $container */ | ||
$container = ...; | ||
|
||
$factory = [ApiExceptionMiddlewareFactory::class, 'default']; | ||
|
||
$apiExceptionMiddleware = $factory($container); | ||
``` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# RequestManagerFactory | ||
|
||
## without name (default) | ||
|
||
```php | ||
<?php | ||
|
||
use Chubbyphp\ApiHttp\Container\RequestManagerFactory; | ||
use Psr\Container\ContainerInterface; | ||
|
||
/** @var ContainerInterface $container */ | ||
$container = ...; | ||
|
||
$factory = new RequestManagerFactory(); | ||
|
||
$requestManager = $factory($container); | ||
``` | ||
|
||
## with name `default` | ||
|
||
```php | ||
<?php | ||
|
||
use Chubbyphp\ApiHttp\Container\RequestManagerFactory; | ||
use Psr\Container\ContainerInterface; | ||
|
||
/** @var ContainerInterface $container */ | ||
$container = ...; | ||
|
||
$factory = [RequestManagerFactory::class, 'default']; | ||
|
||
$requestManager = $factory($container); | ||
``` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# ResponseManagerFactory | ||
|
||
## without name (default) | ||
|
||
```php | ||
<?php | ||
|
||
use Chubbyphp\ApiHttp\Container\ResponseManagerFactory; | ||
use Psr\Container\ContainerInterface; | ||
|
||
/** @var ContainerInterface $container */ | ||
$container = ...; | ||
|
||
$factory = new ResponseManagerFactory(); | ||
|
||
$responseManager = $factory($container); | ||
``` | ||
|
||
## with name `default` | ||
|
||
```php | ||
<?php | ||
|
||
use Chubbyphp\ApiHttp\Container\ResponseManagerFactory; | ||
use Psr\Container\ContainerInterface; | ||
|
||
/** @var ContainerInterface $container */ | ||
$container = ...; | ||
|
||
$factory = [ResponseManagerFactory::class, 'default']; | ||
|
||
$responseManager = $factory($container); | ||
``` |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
43 changes: 43 additions & 0 deletions
43
src/ServiceFactory/AcceptAndContentTypeMiddlewareFactory.php
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Chubbyphp\ApiHttp\ServiceFactory; | ||
|
||
use Chubbyphp\ApiHttp\Manager\ResponseManagerInterface; | ||
use Chubbyphp\ApiHttp\Middleware\AcceptAndContentTypeMiddleware; | ||
use Chubbyphp\Laminas\Config\Factory\AbstractFactory; | ||
use Chubbyphp\Negotiation\AcceptNegotiatorInterface; | ||
use Chubbyphp\Negotiation\ContentTypeNegotiatorInterface; | ||
use Chubbyphp\Negotiation\ServiceFactory\AcceptNegotiatorFactory; | ||
use Chubbyphp\Negotiation\ServiceFactory\ContentTypeNegotiatorFactory; | ||
use Psr\Container\ContainerInterface; | ||
|
||
final class AcceptAndContentTypeMiddlewareFactory extends AbstractFactory | ||
{ | ||
public function __invoke(ContainerInterface $container): AcceptAndContentTypeMiddleware | ||
{ | ||
/** @var AcceptNegotiatorInterface $acceptNegotiator */ | ||
$acceptNegotiator = $this->resolveDependency( | ||
$container, | ||
AcceptNegotiatorInterface::class, | ||
AcceptNegotiatorFactory::class | ||
); | ||
|
||
/** @var ContentTypeNegotiatorInterface $contentTypeNegotiator */ | ||
$contentTypeNegotiator = $this->resolveDependency( | ||
$container, | ||
ContentTypeNegotiatorInterface::class, | ||
ContentTypeNegotiatorFactory::class | ||
); | ||
|
||
/** @var ResponseManagerInterface $responseManager */ | ||
$responseManager = $this->resolveDependency( | ||
$container, | ||
ResponseManagerInterface::class, | ||
ResponseManagerFactory::class | ||
); | ||
|
||
return new AcceptAndContentTypeMiddleware($acceptNegotiator, $contentTypeNegotiator, $responseManager); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Chubbyphp\ApiHttp\ServiceFactory; | ||
|
||
use Chubbyphp\ApiHttp\Manager\ResponseManagerInterface; | ||
use Chubbyphp\ApiHttp\Middleware\ApiExceptionMiddleware; | ||
use Chubbyphp\Laminas\Config\Factory\AbstractFactory; | ||
use Psr\Container\ContainerInterface; | ||
use Psr\Log\LoggerInterface; | ||
use Psr\Log\NullLogger; | ||
|
||
final class ApiExceptionMiddlewareFactory extends AbstractFactory | ||
{ | ||
public function __invoke(ContainerInterface $container): ApiExceptionMiddleware | ||
{ | ||
/** @var ResponseManagerInterface $responseManager */ | ||
$responseManager = $this->resolveDependency( | ||
$container, | ||
ResponseManagerInterface::class, | ||
ResponseManagerFactory::class | ||
); | ||
|
||
return new ApiExceptionMiddleware( | ||
$responseManager, | ||
$container->get('config')['debug'], | ||
$container->has(LoggerInterface::class) ? $container->get(LoggerInterface::class) : new NullLogger() | ||
); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Chubbyphp\ApiHttp\ServiceFactory; | ||
|
||
use Chubbyphp\ApiHttp\Manager\RequestManager; | ||
use Chubbyphp\ApiHttp\Manager\RequestManagerInterface; | ||
use Chubbyphp\Deserialization\DeserializerInterface; | ||
use Chubbyphp\Deserialization\ServiceFactory\DeserializerFactory; | ||
use Chubbyphp\Laminas\Config\Factory\AbstractFactory; | ||
use Psr\Container\ContainerInterface; | ||
|
||
final class RequestManagerFactory extends AbstractFactory | ||
{ | ||
public function __invoke(ContainerInterface $container): RequestManagerInterface | ||
{ | ||
/** @var DeserializerInterface $deserializer */ | ||
$deserializer = $this->resolveDependency($container, DeserializerInterface::class, DeserializerFactory::class); | ||
|
||
return new RequestManager($deserializer); | ||
} | ||
} |
Oops, something went wrong.