0
0
Fork 0
mirror of https://github.com/salesagility/SuiteCRM.git synced 2025-02-06 06:50:04 +00:00
salesagility_SuiteCRM/Api/V8/Factory/ParamsMiddlewareFactory.php
2020-01-28 17:06:26 +00:00

40 lines
948 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;
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);
};
}
}