0
0
mirror of https://github.com/salesagility/SuiteCRM.git synced 2024-11-24 00:29:35 +00:00
salesagility_SuiteCRM/Api/V8/Factory/ParamsMiddlewareFactory.php
2023-07-18 15:53:08 +01:00

42 lines
975 B
PHP

<?php
namespace Api\V8\Factory;
use Api\V8\Middleware\ParamsMiddleware;
use Psr\Container\ContainerInterface as Container;
use Slim\Http\Request;
use Slim\Http\Response;
use Api\V8\BeanDecorator\BeanManager;
#[\AllowDynamicProperties]
class ParamsMiddlewareFactory
{
/**
* @var Container
*/
protected $container;
/**
* @param Container $container
*/
public function __construct(Container $container)
{
$this->container = $container;
}
/**
* @param string $containerId
*
* @return callable
*/
public function bind($containerId)
{
$container = $this->container;
return function (Request $request, Response $response, callable $next) use ($containerId, $container) {
$paramMiddleware = new ParamsMiddleware($container->get($containerId), $container->get(BeanManager::class));
return $paramMiddleware($request, $response, $next);
};
}
}