Class Yiisoft\Yii\Debug\Api\Inspector\Controller\CacheController
| Inheritance | Yiisoft\Yii\Debug\Api\Inspector\Controller\CacheController |
|---|
Public Methods
Method Details
| public mixed __construct ( \Yiisoft\DataResponse\DataResponseFactoryInterface $responseFactory ) | ||
| $responseFactory | \Yiisoft\DataResponse\DataResponseFactoryInterface | |
public function __construct(
private DataResponseFactoryInterface $responseFactory,
) {
}
| public \Psr\Http\Message\ResponseInterface clear ( \Psr\Container\ContainerInterface $container ) | ||
| $container | \Psr\Container\ContainerInterface | |
public function clear(
ContainerInterface $container,
): ResponseInterface {
if (!$container->has(CacheInterface::class)) {
// TODO: fix message
throw new RuntimeException(
'Psr\\SimpleCache\\CacheInterface does not exist in the application configuration.'
);
}
$cache = $container->get(CacheInterface::class);
$result = $cache->clear();
return $this->responseFactory->createResponse([
'result' => $result,
]);
}
| public \Psr\Http\Message\ResponseInterface delete ( \Psr\Http\Message\ServerRequestInterface $request, \Psr\Container\ContainerInterface $container ) | ||
| $request | \Psr\Http\Message\ServerRequestInterface | |
| $container | \Psr\Container\ContainerInterface | |
public function delete(
ServerRequestInterface $request,
ContainerInterface $container,
): ResponseInterface {
$params = $request->getQueryParams();
$key = $params['key'] ?? '';
if ($key === '') {
throw new RuntimeException('Cache key must not be empty.');
}
if (!$container->has(CacheInterface::class)) {
// TODO: fix message
throw new RuntimeException(
'Psr\\SimpleCache\\CacheInterface does not exist in the application configuration.'
);
}
$cache = $container->get(CacheInterface::class);
if (!$cache->has($key)) {
throw new RuntimeException('Key does not exist in cache');
}
$result = $cache->delete($key);
return $this->responseFactory->createResponse([
'result' => $result,
]);
}
| public \Psr\Http\Message\ResponseInterface view ( \Psr\Http\Message\ServerRequestInterface $request, \Psr\Container\ContainerInterface $container ) | ||
| $request | \Psr\Http\Message\ServerRequestInterface | |
| $container | \Psr\Container\ContainerInterface | |
public function view(
ServerRequestInterface $request,
ContainerInterface $container,
): ResponseInterface {
$params = $request->getQueryParams();
$key = $params['key'] ?? '';
if ($key === '') {
throw new RuntimeException('Cache key must not be empty.');
}
if (!$container->has(CacheInterface::class)) {
// TODO: fix message
throw new RuntimeException(
'Psr\\SimpleCache\\CacheInterface does not exist in the application configuration.'
);
}
$cache = $container->get(CacheInterface::class);
if (!$cache->has($key)) {
return $this->responseFactory->createResponse([
'error' => 'Key does not exist in cache',
], 404);
}
$result = $cache->get($key);
$response = VarDumper::create($result)->asPrimitives(255);
return $this->responseFactory->createResponse($response);
}
Signup or Login in order to comment.