for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* BEdita, API-first content management framework
* Copyright 2022 ChannelWeb Srl, Chialab Srl
*
* This file is part of BEdita: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* See LICENSE.LGPL or <http://gnu.org/licenses/lgpl-3.0.html> for more details.
*/
namespace App\Middleware;
use App\Utility\ApiConfigTrait;
use BEdita\WebTools\ApiClientProvider;
use Cake\Core\Configure;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
* Configuration middleware.
* Load configuration from API using cache.
class ConfigurationMiddleware implements MiddlewareInterface
{
use ApiConfigTrait;
* @inheritDoc
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
if (Configure::check('API.apiBaseUrl')) {
$identity = $request->getAttribute('identity');
if ($identity && $identity->get('tokens')) {
ApiClientProvider::getApiClient()->setupTokens($identity->get('tokens'));
}
$this->readApiConfig();
return $handler->handle($request);