/home/rdc/rdc.refugee/production/vendor/willdurand/negotiation/src/Negotiation/AbstractNegotiator.php
use Negotiation\Exception\InvalidArgument;
use Negotiation\Exception\InvalidHeader;
abstract class AbstractNegotiator
{
/**
* @param string $header A string containing an `Accept|Accept-*` header.
* @param array $priorities A set of server priorities.
*
* @return AcceptHeader|null best matching type
*/
public function getBest($header, array $priorities, $strict = false)
{
if (empty($priorities)) {
throw new InvalidArgument('A set of server priorities should be given.');
}
if (!$header) {
throw new InvalidArgument('The header string should not be empty.');
}
// Once upon a time, two `array_map` calls were sitting there, but for
// some reasons, they triggered `E_WARNING` time to time (because of
// PHP bug [55416](https://bugs.php.net/bug.php?id=55416). Now, they
// are gone.
// See: https://github.com/willdurand/Negotiation/issues/81
$acceptedHeaders = array();
foreach ($this->parseHeader($header) as $h) {
try {
$acceptedHeaders[] = $this->acceptFactory($h);
} catch (Exception\Exception $e) {
if ($strict) {
throw $e;
}
}
}
$acceptedPriorities = array();
foreach ($priorities as $p) {
$acceptedPriorities[] = $this->acceptFactory($p);
/home/rdc/rdc.refugee/production/src/Http/Home/Responder.php
declare(strict_types=1);
namespace App\Http\Home;
use App\Http\Responder as BaseResponder;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
use Slim\Views\PhpRenderer;
use Aura\Auth\Auth;
class Responder extends BaseResponder
{
protected function found() : void
{
$negotiator = new \Negotiation\LanguageNegotiator();
$header = $this->request->getHeaderLine('Accept-Language');
$langs = $this->payload->getResult()['langs'];
$bestLanguage = $negotiator->getBest($header, $langs);
$code = $bestLanguage ? $bestLanguage->getType() : 'en';
$this->redirect("/$code");
}
}
/home/rdc/rdc.refugee/production/vendor/jnjxp/adr/src/Respond/AbstractResponder.php
public static function accepts() : array
{
return ['application/json'];
}
public function __construct(ResponseFactoryInterface $responseFactory)
{
$this->responseFactory = $responseFactory;
}
public function __invoke(
ServerRequestInterface $request,
DomainPayload $payload = null
) : ResponseInterface {
$this->request = $request;
$this->payload = $payload;
$this->response = $this->responseFactory->createResponse();
$this->init();
$method = $this->getMethod();
$this->$method();
return $this->response;
}
protected function init() : void
{
}
protected function getMethod() : string
{
if (! $this->payload) {
return 'noContent';
}
$method = str_replace('_', '', strtolower($this->payload->getStatus()));
return method_exists($this, $method) ? $method : 'unknown';
}
protected function noContent() : void
{
$this->response = $this->response->withStatus(self::STATUS_NO_CONTENT);
/home/rdc/rdc.refugee/production/vendor/jnjxp/adr/src/Process/AbstractActionHandler.php
protected function act(ServerRequestInterface $request, ActionInterface $action) : ResponseInterface
{
$responder = $this->getResponder($action);
if (! $responder) {
throw new \Exception('No Responder!');
}
$domain = $this->getDomain($action);
if (! $domain) {
return $responder($request);
}
$input = $this->getInput($action);
$params = $input ? (array) $input($request) : [];
$payload = call_user_func_array($domain, $params);
return $responder($request, $payload);
}
abstract protected function getResponder(ActionInterface $action) : callable;
abstract protected function getDomain(ActionInterface $action) : ?callable;
abstract protected function getInput(ActionInterface $action) : ?callable;
}
/home/rdc/rdc.refugee/production/vendor/jnjxp/adr/src/Process/AbstractActionHandler.php
namespace Jnjxp\Adr\Process;
use Jnjxp\Adr\Action\ActionInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
abstract class AbstractActionHandler implements MiddlewareInterface, RequestHandlerInterface
{
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$handler = $this->actionable($request) ? $this : $handler;
return $handler->handle($request);
}
public function handle(ServerRequestInterface $request) : ResponseInterface
{
$action = $this->getAction($request);
return $this->act($request, $action);
}
protected function actionable(ServerRequestInterface $request) : bool
{
return (bool) $this->getAction($request);
}
protected function getAction(ServerRequestInterface $request) : ?ActionInterface
{
$action = $request->getAttribute(ActionInterface::class);
return ($action && $action instanceof ActionInterface) ? $action : null;
}
protected function act(ServerRequestInterface $request, ActionInterface $action) : ResponseInterface
{
$responder = $this->getResponder($action);
if (! $responder) {
throw new \Exception('No Responder!');
}
/home/rdc/rdc.refugee/production/vendor/jnjxp/adr/src/Process/AbstractActionHandler.php
<?php
declare(strict_types = 1);
namespace Jnjxp\Adr\Process;
use Jnjxp\Adr\Action\ActionInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
abstract class AbstractActionHandler implements MiddlewareInterface, RequestHandlerInterface
{
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$handler = $this->actionable($request) ? $this : $handler;
return $handler->handle($request);
}
public function handle(ServerRequestInterface $request) : ResponseInterface
{
$action = $this->getAction($request);
return $this->act($request, $action);
}
protected function actionable(ServerRequestInterface $request) : bool
{
return (bool) $this->getAction($request);
}
protected function getAction(ServerRequestInterface $request) : ?ActionInterface
{
$action = $request->getAttribute(ActionInterface::class);
return ($action && $action instanceof ActionInterface) ? $action : null;
}
protected function act(ServerRequestInterface $request, ActionInterface $action) : ResponseInterface
{
$responder = $this->getResponder($action);
/home/rdc/rdc.refugee/production/vendor/laminas/laminas-stratigility/src/Next.php
$this->queue = clone $queue;
$this->fallbackHandler = $fallbackHandler;
}
public function handle(ServerRequestInterface $request): ResponseInterface
{
if ($this->queue === null) {
throw MiddlewarePipeNextHandlerAlreadyCalledException::create();
}
if ($this->queue->isEmpty()) {
$this->queue = null;
return $this->fallbackHandler->handle($request);
}
$middleware = $this->queue->dequeue();
$next = clone $this; // deep clone is not used intentionally
$this->queue = null; // mark queue as processed at this nesting level
return $middleware->process($request, $next);
}
}
/home/rdc/rdc.refugee/production/vendor/jnjxp/aura-adr/src/AuraRouteAction.php
class AuraRouteAction implements MiddlewareInterface
{
protected $actionFactory;
public function __construct(ActionFactoryInterface $actionFactory = null)
{
$this->actionFactory = $actionFactory ?? new ActionFactory();
}
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface
{
$route = $request->getAttribute(AuraRoute::class);
if ($route && $route instanceof Route) {
$action = $this->newAction($route);
$request = $request->withAttribute(ActionInterface::class, $action);
}
return $handler->handle($request);
}
protected function newAction(Route $route) : ActionInterface
{
return $this->actionFactory->newAction(
$route->input,
$route->domain,
$route->responder
);
}
}
/home/rdc/rdc.refugee/production/vendor/laminas/laminas-stratigility/src/Next.php
$this->queue = clone $queue;
$this->fallbackHandler = $fallbackHandler;
}
public function handle(ServerRequestInterface $request): ResponseInterface
{
if ($this->queue === null) {
throw MiddlewarePipeNextHandlerAlreadyCalledException::create();
}
if ($this->queue->isEmpty()) {
$this->queue = null;
return $this->fallbackHandler->handle($request);
}
$middleware = $this->queue->dequeue();
$next = clone $this; // deep clone is not used intentionally
$this->queue = null; // mark queue as processed at this nesting level
return $middleware->process($request, $next);
}
}
/home/rdc/rdc.refugee/production/vendor/jnjxp/router/src/Process/AbstractRouteRequest.php
<?php
declare(strict_types = 1);
namespace Jnjxp\Router\Process;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
abstract class AbstractRouteRequest implements MiddlewareInterface
{
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$request = $this->match($request)
? $this->matched($request)
: $this->unmatched($request);
return $handler->handle($request);
}
abstract protected function match(ServerRequestInterface $request) : bool;
abstract protected function matched(ServerRequestInterface $request) : ServerRequestInterface;
protected function unmatched(ServerRequestInterface $request) : ServerRequestInterface
{
return $request;
}
}
/home/rdc/rdc.refugee/production/vendor/laminas/laminas-stratigility/src/Next.php
$this->queue = clone $queue;
$this->fallbackHandler = $fallbackHandler;
}
public function handle(ServerRequestInterface $request): ResponseInterface
{
if ($this->queue === null) {
throw MiddlewarePipeNextHandlerAlreadyCalledException::create();
}
if ($this->queue->isEmpty()) {
$this->queue = null;
return $this->fallbackHandler->handle($request);
}
$middleware = $this->queue->dequeue();
$next = clone $this; // deep clone is not used intentionally
$this->queue = null; // mark queue as processed at this nesting level
return $middleware->process($request, $next);
}
}
/home/rdc/rdc.refugee/production/vendor/laminas/laminas-stratigility/src/Middleware/PathMiddlewareDecorator.php
final class PathMiddlewareDecorator implements MiddlewareInterface
{
private MiddlewareInterface $middleware;
/** @var string Path prefix under which the middleware is segregated. */
private string $prefix;
public function __construct(string $prefix, MiddlewareInterface $middleware)
{
$this->prefix = $this->normalizePrefix($prefix);
$this->middleware = $middleware;
}
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$path = $request->getUri()->getPath() ?: '/';
// Current path is shorter than decorator path
if (strlen($path) < strlen($this->prefix)) {
return $handler->handle($request);
}
// Current path does not match decorator path
if (0 !== stripos($path, $this->prefix)) {
return $handler->handle($request);
}
// Skip if match is not at a border ('/' or end)
$border = $this->getBorder($path);
if ($border && '/' !== $border) {
return $handler->handle($request);
}
// Trim off the part of the url that matches the prefix if it is not / only
$requestToProcess = $this->prefix !== '/'
? $this->prepareRequestWithTruncatedPrefix($request)
: $request;
// Process our middleware.
// If the middleware calls on the handler, the handler should be provided
/home/rdc/rdc.refugee/production/vendor/laminas/laminas-stratigility/src/Next.php
$this->queue = clone $queue;
$this->fallbackHandler = $fallbackHandler;
}
public function handle(ServerRequestInterface $request): ResponseInterface
{
if ($this->queue === null) {
throw MiddlewarePipeNextHandlerAlreadyCalledException::create();
}
if ($this->queue->isEmpty()) {
$this->queue = null;
return $this->fallbackHandler->handle($request);
}
$middleware = $this->queue->dequeue();
$next = clone $this; // deep clone is not used intentionally
$this->queue = null; // mark queue as processed at this nesting level
return $middleware->process($request, $next);
}
}
/home/rdc/rdc.refugee/production/vendor/laminas/laminas-stratigility/src/Middleware/PathMiddlewareDecorator.php
final class PathMiddlewareDecorator implements MiddlewareInterface
{
private MiddlewareInterface $middleware;
/** @var string Path prefix under which the middleware is segregated. */
private string $prefix;
public function __construct(string $prefix, MiddlewareInterface $middleware)
{
$this->prefix = $this->normalizePrefix($prefix);
$this->middleware = $middleware;
}
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$path = $request->getUri()->getPath() ?: '/';
// Current path is shorter than decorator path
if (strlen($path) < strlen($this->prefix)) {
return $handler->handle($request);
}
// Current path does not match decorator path
if (0 !== stripos($path, $this->prefix)) {
return $handler->handle($request);
}
// Skip if match is not at a border ('/' or end)
$border = $this->getBorder($path);
if ($border && '/' !== $border) {
return $handler->handle($request);
}
// Trim off the part of the url that matches the prefix if it is not / only
$requestToProcess = $this->prefix !== '/'
? $this->prepareRequestWithTruncatedPrefix($request)
: $request;
// Process our middleware.
// If the middleware calls on the handler, the handler should be provided
/home/rdc/rdc.refugee/production/vendor/laminas/laminas-stratigility/src/Next.php
$this->queue = clone $queue;
$this->fallbackHandler = $fallbackHandler;
}
public function handle(ServerRequestInterface $request): ResponseInterface
{
if ($this->queue === null) {
throw MiddlewarePipeNextHandlerAlreadyCalledException::create();
}
if ($this->queue->isEmpty()) {
$this->queue = null;
return $this->fallbackHandler->handle($request);
}
$middleware = $this->queue->dequeue();
$next = clone $this; // deep clone is not used intentionally
$this->queue = null; // mark queue as processed at this nesting level
return $middleware->process($request, $next);
}
}
/home/rdc/rdc.refugee/production/vendor/jnjxp/auth/src/Middleware/ResumeAuthentication.php
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
class ResumeAuthentication implements MiddlewareInterface
{
private $auth;
private $resume;
public function __construct(Auth $auth, ResumeService $resume)
{
$this->auth = $auth;
$this->resume = $resume;
}
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$request = $this->withAuthentication($request);
return $handler->handle($request);
}
protected function withAuthentication(ServerRequestInterface $request) : ServerRequestInterface
{
$this->resumeAuth();
return $request->withAttribute(Auth::class, $this->auth);
}
protected function resumeAuth() : void
{
$this->resume->resume($this->auth);
}
}
/home/rdc/rdc.refugee/production/vendor/laminas/laminas-stratigility/src/Next.php
$this->queue = clone $queue;
$this->fallbackHandler = $fallbackHandler;
}
public function handle(ServerRequestInterface $request): ResponseInterface
{
if ($this->queue === null) {
throw MiddlewarePipeNextHandlerAlreadyCalledException::create();
}
if ($this->queue->isEmpty()) {
$this->queue = null;
return $this->fallbackHandler->handle($request);
}
$middleware = $this->queue->dequeue();
$next = clone $this; // deep clone is not used intentionally
$this->queue = null; // mark queue as processed at this nesting level
return $middleware->process($request, $next);
}
}
/home/rdc/rdc.refugee/production/vendor/middlewares/aura-session/src/AuraSession.php
$this->attribute = $attribute;
return $this;
}
/**
* Process a server request and return a response.
*/
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$factory = $this->factory ?: new SessionFactory();
$session = $factory->newInstance($request->getCookieParams());
if ($this->name !== null) {
$session->setName($this->name);
}
$request = $request->withAttribute($this->attribute, $session);
return $handler->handle($request);
}
}
/home/rdc/rdc.refugee/production/vendor/laminas/laminas-stratigility/src/Next.php
$this->queue = clone $queue;
$this->fallbackHandler = $fallbackHandler;
}
public function handle(ServerRequestInterface $request): ResponseInterface
{
if ($this->queue === null) {
throw MiddlewarePipeNextHandlerAlreadyCalledException::create();
}
if ($this->queue->isEmpty()) {
$this->queue = null;
return $this->fallbackHandler->handle($request);
}
$middleware = $this->queue->dequeue();
$next = clone $this; // deep clone is not used intentionally
$this->queue = null; // mark queue as processed at this nesting level
return $middleware->process($request, $next);
}
}
/home/rdc/rdc.refugee/production/vendor/jnjxp/production-host/src/ProductionHost.php
class ProductionHost implements MiddlewareInterface, StatusCodeInterface
{
protected $responseFactory;
protected $host;
protected $status = self::STATUS_TEMPORARY_REDIRECT;
public function __construct(ResponseFactoryInterface $responseFactory, string $host = null)
{
$this->responseFactory = $responseFactory;
$this->host = $host ? trim($host) : null;
}
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
if ($this->host) {
return $this->redirect($request);
}
return $handler->handle($request);
}
protected function redirect(ServerRequestInterface $request) : ResponseInterface
{
$uri = $request->getUri()->withHost($this->host);
return $this->createResponse()->withHeader('Location', (string) $uri);
}
protected function createResponse() : ResponseInterface
{
return $this->responseFactory->createResponse($this->status);
}
}
/home/rdc/rdc.refugee/production/vendor/laminas/laminas-stratigility/src/Next.php
$this->queue = clone $queue;
$this->fallbackHandler = $fallbackHandler;
}
public function handle(ServerRequestInterface $request): ResponseInterface
{
if ($this->queue === null) {
throw MiddlewarePipeNextHandlerAlreadyCalledException::create();
}
if ($this->queue->isEmpty()) {
$this->queue = null;
return $this->fallbackHandler->handle($request);
}
$middleware = $this->queue->dequeue();
$next = clone $this; // deep clone is not used intentionally
$this->queue = null; // mark queue as processed at this nesting level
return $middleware->process($request, $next);
}
}
/home/rdc/rdc.refugee/production/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php
* If the pipeline is empty at the time this method is invoked, it will
* raise an exception.
*
* @throws Exception\EmptyPipelineException If no middleware is present in
* the instance in order to process the request.
*/
public function handle(ServerRequestInterface $request): ResponseInterface
{
return $this->process($request, new EmptyPipelineHandler(self::class));
}
/**
* PSR-15 middleware invocation.
*
* Executes the internal pipeline, passing $handler as the "final
* handler" in cases when the pipeline exhausts itself.
*/
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
return (new Next($this->pipeline, $handler))->handle($request);
}
/**
* Attach middleware to the pipeline.
*/
public function pipe(MiddlewareInterface $middleware): void
{
$this->pipeline->enqueue($middleware);
}
}
/home/rdc/rdc.refugee/production/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php
}
/**
* Handle an incoming request.
*
* Attempts to handle an incoming request by doing the following:
*
* - Cloning itself, to produce a request handler.
* - Dequeuing the first middleware in the cloned handler.
* - Processing the first middleware using the request and the cloned handler.
*
* If the pipeline is empty at the time this method is invoked, it will
* raise an exception.
*
* @throws Exception\EmptyPipelineException If no middleware is present in
* the instance in order to process the request.
*/
public function handle(ServerRequestInterface $request): ResponseInterface
{
return $this->process($request, new EmptyPipelineHandler(self::class));
}
/**
* PSR-15 middleware invocation.
*
* Executes the internal pipeline, passing $handler as the "final
* handler" in cases when the pipeline exhausts itself.
*/
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
return (new Next($this->pipeline, $handler))->handle($request);
}
/**
* Attach middleware to the pipeline.
*/
public function pipe(MiddlewareInterface $middleware): void
{
$this->pipeline->enqueue($middleware);
}
/home/rdc/rdc.refugee/production/vendor/laminas/laminas-httphandlerrunner/src/RequestHandlerRunner.php
$this->serverRequestErrorResponseGenerator =
function (Throwable $exception) use ($serverRequestErrorResponseGenerator) : ResponseInterface {
return $serverRequestErrorResponseGenerator($exception);
};
}
/**
* Run the application
*/
public function run() : void
{
try {
$request = ($this->serverRequestFactory)();
} catch (Throwable $e) {
// Error in generating the request
$this->emitMarshalServerRequestException($e);
return;
}
$response = $this->handler->handle($request);
$this->emitter->emit($response);
}
private function emitMarshalServerRequestException(Throwable $exception) : void
{
$response = ($this->serverRequestErrorResponseGenerator)($exception);
$this->emitter->emit($response);
}
}
/home/rdc/rdc.refugee/production/vendor/jnjxp/app/src/App.php
protected $emitter;
protected $serverRequestCreator;
protected $errorGenerator;
public function __construct(
EmitterInterface $emitter,
ServerRequestCreatorInterface $serverRequestCreator,
callable $errorGenerator
) {
$this->emitter = $emitter;
$this->serverRequestCreator = $serverRequestCreator;
$this->errorGenerator = $errorGenerator;
}
public function run(RequestHandlerInterface $pipe) : void
{
$runner = $this->newRunner($pipe);
$runner->run();
}
protected function newRunner(RequestHandlerInterface $pipe) : RequestHandlerRunner
{
return new RequestHandlerRunner(
$pipe,
$this->emitter,
[$this->serverRequestCreator, 'fromGlobals'],
$this->errorGenerator
);
}
}
/home/rdc/rdc.refugee/production/public/index.php
// Delegate static file requests back to the PHP built-in webserver
if (PHP_SAPI === 'cli-server' && $_SERVER['SCRIPT_FILENAME'] !== __FILE__) {
return false;
}
chdir(dirname(__DIR__));
require 'vendor/autoload.php';
require 'config/i18n.php';
(function () {
$container = require 'config/container.php';
if ($container->get('DEBUG')) {
require 'config/debug.php';
}
$pipe = (require 'config/pipe.php')($container);
$app = $container->get(App::class);
$app->run($pipe);
})();
/home/rdc/rdc.refugee/production/public/index.php
if (PHP_SAPI === 'cli-server' && $_SERVER['SCRIPT_FILENAME'] !== __FILE__) {
return false;
}
chdir(dirname(__DIR__));
require 'vendor/autoload.php';
require 'config/i18n.php';
(function () {
$container = require 'config/container.php';
if ($container->get('DEBUG')) {
require 'config/debug.php';
}
$pipe = (require 'config/pipe.php')($container);
$app = $container->get(App::class);
$app->run($pipe);
})();