/home/copelibrxp/www/vendor/symfony/translation/Translator.php
private $debug;
private $cacheVary;
/**
* @var ConfigCacheFactoryInterface|null
*/
private $configCacheFactory;
/**
* @var array|null
*/
private $parentLocales;
private $hasIntlFormatter;
/**
* @throws InvalidArgumentException If a locale contains invalid characters
*/
public function __construct(?string $locale, MessageFormatterInterface $formatter = null, string $cacheDir = null, bool $debug = false, array $cacheVary = [])
{
if (null === $locale) {
@trigger_error(sprintf('Passing "null" as the $locale argument to %s() is deprecated since Symfony 4.4.', __METHOD__), \E_USER_DEPRECATED);
}
$this->setLocale($locale, false);
if (null === $formatter) {
$formatter = new MessageFormatter();
}
$this->formatter = $formatter;
$this->cacheDir = $cacheDir;
$this->debug = $debug;
$this->cacheVary = $cacheVary;
$this->hasIntlFormatter = $formatter instanceof IntlFormatterInterface;
}
public function setConfigCacheFactory(ConfigCacheFactoryInterface $configCacheFactory)
{
/home/copelibrxp/www/vendor/composer/ClassLoader.php
/**
* @return void
*/
private static function initializeIncludeClosure()
{
if (self::$includeFile !== null) {
return;
}
/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*
* @param string $file
* @return void
*/
self::$includeFile = \Closure::bind(static function($file) {
include $file;
}, null, null);
}
}
/home/copelibrxp/www/vendor/composer/ClassLoader.php
/**
* @return void
*/
private static function initializeIncludeClosure()
{
if (self::$includeFile !== null) {
return;
}
/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*
* @param string $file
* @return void
*/
self::$includeFile = \Closure::bind(static function($file) {
include $file;
}, null, null);
}
}
/home/copelibrxp/www/vendor/composer/ClassLoader.php
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));
if (null !== $this->vendorDir) {
unset(self::$registeredLoaders[$this->vendorDir]);
}
}
/**
* Loads the given class or interface.
*
* @param string $class The name of the class
* @return true|null True if loaded, null otherwise
*/
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
$includeFile = self::$includeFile;
$includeFile($file);
return true;
}
return null;
}
/**
* Finds the path to the file where the class is defined.
*
* @param string $class The name of the class
*
* @return string|false The path if found, false otherwise
*/
public function findFile($class)
{
// class map lookup
if (isset($this->classMap[$class])) {
return $this->classMap[$class];
}
/home/copelibrxp/www/src/dependencies.php
$container['flash'] = function ($c) {
return new \Slim\Flash\Messages();
};
// eloquent
// Needs to be bootstrapped before being injected in $container
$capsule = new \Illuminate\Database\Capsule\Manager;
$capsule->addConnection($container['settings']['db']);
$capsule->setAsGlobal();
$capsule->bootEloquent();
$container['db'] = function ($c) use ($capsule) {
return $capsule;
};
// symfony/translation
$container['translator'] = function ($c) {
$settings = $c->get('settings')['translator'];
// $translator = new Translator($settings['default'], new MessageSelector());
$translator = new Translator($settings['default']);
// Set a fallback language incase you don't have a translation in the default language
$translator->setFallbackLocales($settings['fallback']);
// Add a loader that will get the php files we are going to store our translations in
$translator->addLoader('php', new PhpFileLoader());
// Add language files here
foreach ($settings['enabled'] as $language) {
$translator->addResource('php', $settings['resource_path'] . '/' . $language . '.php', $language);
}
return $translator;
};
// twig
// Flash messages
$container['flash'] = function () {
return new \Slim\Flash\Messages();
};
$container['view'] = function ($c) {
$settings = $c->get('settings')['twig'];
/home/copelibrxp/www/vendor/pimple/pimple/src/Pimple/Container.php
{
if (!isset($this->keys[$id])) {
throw new UnknownIdentifierException($id);
}
if (
isset($this->raw[$id])
|| !\is_object($this->values[$id])
|| isset($this->protected[$this->values[$id]])
|| !\method_exists($this->values[$id], '__invoke')
) {
return $this->values[$id];
}
if (isset($this->factories[$this->values[$id]])) {
return $this->values[$id]($this);
}
$raw = $this->values[$id];
$val = $this->values[$id] = $raw($this);
$this->raw[$id] = $raw;
$this->frozen[$id] = true;
return $val;
}
/**
* Checks if a parameter or an object is set.
*
* @param string $id The unique identifier for the parameter or object
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function offsetExists($id)
{
return isset($this->keys[$id]);
}
/home/copelibrxp/www/vendor/slim/slim/Slim/Container.php
/**
* Finds an entry of the container by its identifier and returns it.
*
* @param string $id Identifier of the entry to look for.
*
* @return mixed
*
* @throws InvalidArgumentException Thrown when an offset cannot be found in the Pimple container
* @throws SlimContainerException Thrown when an exception is
* not an instance of ContainerExceptionInterface
* @throws ContainerValueNotFoundException No entry was found for this identifier.
* @throws ContainerExceptionInterface Error while retrieving the entry.
*/
public function get($id)
{
if (!$this->offsetExists($id)) {
throw new ContainerValueNotFoundException(sprintf('Identifier "%s" is not defined.', $id));
}
try {
return $this->offsetGet($id);
} catch (InvalidArgumentException $exception) {
if ($this->exceptionThrownByContainer($exception)) {
throw new SlimContainerException(
sprintf('Container error while retrieving "%s"', $id),
null,
$exception
);
} else {
throw $exception;
}
}
}
/**
* Tests whether an exception needs to be recast for compliance with psr/container. This will be if the
* exception was thrown by Pimple.
*
* @param InvalidArgumentException $exception
*
* @return bool
/home/copelibrxp/www/vendor/slim/slim/Slim/Container.php
*/
public function has($id)
{
return $this->offsetExists($id);
}
/**
* @param string $name
*
* @return mixed
*
* @throws InvalidArgumentException Thrown when an offset cannot be found in the Pimple container
* @throws SlimContainerException Thrown when an exception is not
* an instance of ContainerExceptionInterface
* @throws ContainerValueNotFoundException No entry was found for this identifier.
* @throws ContainerExceptionInterface Error while retrieving the entry.
*/
public function __get($name)
{
return $this->get($name);
}
/**
* @param string $name
* @return bool
*/
public function __isset($name)
{
return $this->has($name);
}
}
/home/copelibrxp/www/src/routes.php
use Application\Controllers\PurchasePaymentsController;
use Application\Controllers\RestitutionPaymentsController;
use Application\Controllers\SuperadminController;
use Application\Middlewares\AuthMiddleware;
use Application\Middlewares\GuestMiddleware;
// Routes
// DI Container
$container = $app->getContainer();
// Get available languages to validate routes' {lang} argument
$translatorSettings = $container->get('settings')['translator'];
$languagePlaceholder = '/{lang:' . implode('|', $translatorSettings['enabled']) . '}';
// Default route
$app->get('/', function ($request, $response, $args) {
// Redirect to the default language
return $response->withRedirect($this->router->pathFor('home', ['lang' => $this->translator->getLocale()]));
});
// Add the {lang} argument to every route
$app->group($languagePlaceholder, function () use ($container) {
// Routes that should be used only as a guest
$this->group('/auth', function () {
$this->get('/login', AuthController::class . ':getLogin')->setName('auth.login');
$this->get('/register', AuthController::class . ':getRegister')->setName('auth.register');
$this->post('/login', AuthController::class . ':postLogin');
$this->post('/register', AuthController::class . ':postRegister');
$this->get('/set-password', AuthController::class . ':getForgotPassword')->setName('auth.forgot-password');
$this->post('/set-password', AuthController::class . ':postForgotPassword');
})->add(new GuestMiddleware($container));
$this->group('/public', function () {
$this->get('/users/{user_id:[0-9]+}/confirm/{code:[a-z0-9]+}', 'UsersController:getConfirmUser')->setname('users.confirmation');
$this->get('/users/{user_id:[0-9]+}/reset-password/{code:[a-z0-9]+}', 'UsersController:getResetPassword')->setName('users.reset-password');
$this->post('/users/{user_id:[0-9]+}/reset-password/{code:[a-z0-9]+}', 'UsersController:postResetPassword');
})->add(new GuestMiddleware($container));
/home/copelibrxp/www/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php
* as an array of arguments.
*
* @param array|callable $callable
* @param ServerRequestInterface $request
* @param ResponseInterface $response
* @param array $routeArguments
*
* @return ResponseInterface
*/
public function __invoke(
callable $callable,
ServerRequestInterface $request,
ResponseInterface $response,
array $routeArguments
) {
foreach ($routeArguments as $k => $v) {
$request = $request->withAttribute($k, $v);
}
return call_user_func($callable, $request, $response, $routeArguments);
}
}
/home/copelibrxp/www/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php
* as an array of arguments.
*
* @param array|callable $callable
* @param ServerRequestInterface $request
* @param ResponseInterface $response
* @param array $routeArguments
*
* @return ResponseInterface
*/
public function __invoke(
callable $callable,
ServerRequestInterface $request,
ResponseInterface $response,
array $routeArguments
) {
foreach ($routeArguments as $k => $v) {
$request = $request->withAttribute($k, $v);
}
return call_user_func($callable, $request, $response, $routeArguments);
}
}
/home/copelibrxp/www/vendor/slim/slim/Slim/Route.php
public function run(ServerRequestInterface $request, ResponseInterface $response)
{
// Finalise route now that we are about to run it
$this->finalize();
// Traverse middleware stack and fetch updated response
return $this->callMiddlewareStack($request, $response);
}
/**
* {@inheritdoc}
*/
public function __invoke(ServerRequestInterface $request, ResponseInterface $response)
{
$this->callable = $this->resolveCallable($this->callable);
/** @var InvocationStrategyInterface $handler */
$handler = isset($this->container) ? $this->container->get('foundHandler') : new RequestResponse();
$newResponse = $handler($this->callable, $request, $response, $this->arguments);
if ($newResponse instanceof ResponseInterface) {
// if route callback returns a ResponseInterface, then use it
$response = $newResponse;
} elseif (is_string($newResponse)) {
// if route callback returns a string, then append it to the response
if ($response->getBody()->isWritable()) {
$response->getBody()->write($newResponse);
}
}
return $response;
}
}
/home/copelibrxp/www/vendor/slim/slim/Slim/MiddlewareAwareTrait.php
$this->tip = $kernel;
}
/**
* Call middleware stack
*
* @param ServerRequestInterface $request A request object
* @param ResponseInterface $response A response object
*
* @return ResponseInterface
*/
public function callMiddlewareStack(ServerRequestInterface $request, ResponseInterface $response)
{
if (is_null($this->tip)) {
$this->seedMiddlewareStack();
}
/** @var callable $start */
$start = $this->tip;
$this->middlewareLock = true;
$response = $start($request, $response);
$this->middlewareLock = false;
return $response;
}
}
/home/copelibrxp/www/vendor/slim/slim/Slim/Route.php
{
// Remove temp arguments
$this->setArguments($this->savedArguments);
// Add the route arguments
foreach ($arguments as $k => $v) {
$this->setArgument($k, $v, false);
}
}
/**
* {@inheritdoc}
*/
public function run(ServerRequestInterface $request, ResponseInterface $response)
{
// Finalise route now that we are about to run it
$this->finalize();
// Traverse middleware stack and fetch updated response
return $this->callMiddlewareStack($request, $response);
}
/**
* {@inheritdoc}
*/
public function __invoke(ServerRequestInterface $request, ResponseInterface $response)
{
$this->callable = $this->resolveCallable($this->callable);
/** @var InvocationStrategyInterface $handler */
$handler = isset($this->container) ? $this->container->get('foundHandler') : new RequestResponse();
$newResponse = $handler($this->callable, $request, $response, $this->arguments);
if ($newResponse instanceof ResponseInterface) {
// if route callback returns a ResponseInterface, then use it
$response = $newResponse;
} elseif (is_string($newResponse)) {
// if route callback returns a string, then append it to the response
if ($response->getBody()->isWritable()) {
/home/copelibrxp/www/vendor/slim/slim/Slim/App.php
* @throws MethodNotAllowedException
* @throws NotFoundException
*/
public function __invoke(ServerRequestInterface $request, ResponseInterface $response)
{
// Get the route info
$routeInfo = $request->getAttribute('routeInfo');
/** @var RouterInterface $router */
$router = $this->container->get('router');
// If router hasn't been dispatched or the URI changed then dispatch
if (null === $routeInfo || ($routeInfo['request'] !== [$request->getMethod(), (string) $request->getUri()])) {
$request = $this->dispatchRouterAndPrepareRoute($request, $router);
$routeInfo = $request->getAttribute('routeInfo');
}
if ($routeInfo[0] === Dispatcher::FOUND) {
$route = $router->lookupRoute($routeInfo[1]);
return $route->run($request, $response);
} elseif ($routeInfo[0] === Dispatcher::METHOD_NOT_ALLOWED) {
if (!$this->container->has('notAllowedHandler')) {
throw new MethodNotAllowedException($request, $response, $routeInfo[1]);
}
/** @var callable $notAllowedHandler */
$notAllowedHandler = $this->container->get('notAllowedHandler');
return $notAllowedHandler($request, $response, $routeInfo[1]);
}
if (!$this->container->has('notFoundHandler')) {
throw new NotFoundException($request, $response);
}
/** @var callable $notFoundHandler */
$notFoundHandler = $this->container->get('notFoundHandler');
return $notFoundHandler($request, $response);
}
/**
* Perform a sub-request from within an application route
*
/home/copelibrxp/www/vendor/zeuxisoo/slim-whoops/src/Zeuxisoo/Whoops/Provider/Slim/WhoopsMiddleware.php
class WhoopsMiddleware {
private $app = null;
private $handlers = [];
public function __construct(SlimApp $app = null, array $handlers = []) {
$this->app = $app;
$this->handlers = $handlers;
}
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next) {
$app = $this->app !== null ? $this->app : $next;
$whoopsGuard = new WhoopsGuard();
$whoopsGuard->setApp($app);
$whoopsGuard->setRequest($request);
$whoopsGuard->setHandlers($this->handlers);
$whoopsGuard->install();
return $next($request, $response);
}
}
/home/copelibrxp/www/vendor/slim/slim/Slim/DeferredCallable.php
* @return callable|string
*/
public function getCallable()
{
return $this->callable;
}
/**
* @return mixed
*/
public function __invoke()
{
$callable = $this->resolveCallable($this->callable);
if ($callable instanceof Closure) {
$callable = $callable->bindTo($this->container);
}
$args = func_get_args();
return call_user_func_array($callable, $args);
}
}
/home/copelibrxp/www/vendor/slim/slim/Slim/DeferredCallable.php
* @return callable|string
*/
public function getCallable()
{
return $this->callable;
}
/**
* @return mixed
*/
public function __invoke()
{
$callable = $this->resolveCallable($this->callable);
if ($callable instanceof Closure) {
$callable = $callable->bindTo($this->container);
}
$args = func_get_args();
return call_user_func_array($callable, $args);
}
}
/home/copelibrxp/www/vendor/slim/slim/Slim/MiddlewareAwareTrait.php
* @throws UnexpectedValueException If the middleware doesn't return a Psr\Http\Message\ResponseInterface
*/
protected function addMiddleware(callable $callable)
{
if ($this->middlewareLock) {
throw new RuntimeException('Middleware can’t be added once the stack is dequeuing');
}
if (is_null($this->tip)) {
$this->seedMiddlewareStack();
}
$next = $this->tip;
$this->tip = function (
ServerRequestInterface $request,
ResponseInterface $response
) use (
$callable,
$next
) {
$result = call_user_func($callable, $request, $response, $next);
if ($result instanceof ResponseInterface === false) {
throw new UnexpectedValueException(
'Middleware must return instance of \Psr\Http\Message\ResponseInterface'
);
}
return $result;
};
return $this;
}
/**
* Seed middleware stack with first callable
*
* @param callable $kernel The last item to run as middleware
*
* @throws RuntimeException if the stack is seeded more than once
*/
protected function seedMiddlewareStack(callable $kernel = null)
/home/copelibrxp/www/vendor/slim/slim/Slim/MiddlewareAwareTrait.php
* @throws UnexpectedValueException If the middleware doesn't return a Psr\Http\Message\ResponseInterface
*/
protected function addMiddleware(callable $callable)
{
if ($this->middlewareLock) {
throw new RuntimeException('Middleware can’t be added once the stack is dequeuing');
}
if (is_null($this->tip)) {
$this->seedMiddlewareStack();
}
$next = $this->tip;
$this->tip = function (
ServerRequestInterface $request,
ResponseInterface $response
) use (
$callable,
$next
) {
$result = call_user_func($callable, $request, $response, $next);
if ($result instanceof ResponseInterface === false) {
throw new UnexpectedValueException(
'Middleware must return instance of \Psr\Http\Message\ResponseInterface'
);
}
return $result;
};
return $this;
}
/**
* Seed middleware stack with first callable
*
* @param callable $kernel The last item to run as middleware
*
* @throws RuntimeException if the stack is seeded more than once
*/
protected function seedMiddlewareStack(callable $kernel = null)
/home/copelibrxp/www/src/Middlewares/RemoveTrailingSlashMiddleware.php
class RemoveTrailingSlashMiddleware extends Middleware {
public function __invoke($request, $response, $next) {
$uri = $request->getUri();
$path = $uri->getPath();
if ($path != '/' && substr($path, -1) == '/') {
// Permanently redirect paths with a trailing slash
// to their non-trailing counterpart
$uri = $uri->withPath(substr($path, 0, -1));
if ($request->getMethod() == 'GET') {
return $response->withRedirect((string)$uri, 301);
}
else {
return $next($request->withUri($uri), $response);
}
}
return $next($request, $response);
}
}
/home/copelibrxp/www/vendor/slim/slim/Slim/DeferredCallable.php
* @return callable|string
*/
public function getCallable()
{
return $this->callable;
}
/**
* @return mixed
*/
public function __invoke()
{
$callable = $this->resolveCallable($this->callable);
if ($callable instanceof Closure) {
$callable = $callable->bindTo($this->container);
}
$args = func_get_args();
return call_user_func_array($callable, $args);
}
}
/home/copelibrxp/www/vendor/slim/slim/Slim/DeferredCallable.php
* @return callable|string
*/
public function getCallable()
{
return $this->callable;
}
/**
* @return mixed
*/
public function __invoke()
{
$callable = $this->resolveCallable($this->callable);
if ($callable instanceof Closure) {
$callable = $callable->bindTo($this->container);
}
$args = func_get_args();
return call_user_func_array($callable, $args);
}
}
/home/copelibrxp/www/vendor/slim/slim/Slim/MiddlewareAwareTrait.php
* @throws UnexpectedValueException If the middleware doesn't return a Psr\Http\Message\ResponseInterface
*/
protected function addMiddleware(callable $callable)
{
if ($this->middlewareLock) {
throw new RuntimeException('Middleware can’t be added once the stack is dequeuing');
}
if (is_null($this->tip)) {
$this->seedMiddlewareStack();
}
$next = $this->tip;
$this->tip = function (
ServerRequestInterface $request,
ResponseInterface $response
) use (
$callable,
$next
) {
$result = call_user_func($callable, $request, $response, $next);
if ($result instanceof ResponseInterface === false) {
throw new UnexpectedValueException(
'Middleware must return instance of \Psr\Http\Message\ResponseInterface'
);
}
return $result;
};
return $this;
}
/**
* Seed middleware stack with first callable
*
* @param callable $kernel The last item to run as middleware
*
* @throws RuntimeException if the stack is seeded more than once
*/
protected function seedMiddlewareStack(callable $kernel = null)
/home/copelibrxp/www/vendor/slim/slim/Slim/MiddlewareAwareTrait.php
* @throws UnexpectedValueException If the middleware doesn't return a Psr\Http\Message\ResponseInterface
*/
protected function addMiddleware(callable $callable)
{
if ($this->middlewareLock) {
throw new RuntimeException('Middleware can’t be added once the stack is dequeuing');
}
if (is_null($this->tip)) {
$this->seedMiddlewareStack();
}
$next = $this->tip;
$this->tip = function (
ServerRequestInterface $request,
ResponseInterface $response
) use (
$callable,
$next
) {
$result = call_user_func($callable, $request, $response, $next);
if ($result instanceof ResponseInterface === false) {
throw new UnexpectedValueException(
'Middleware must return instance of \Psr\Http\Message\ResponseInterface'
);
}
return $result;
};
return $this;
}
/**
* Seed middleware stack with first callable
*
* @param callable $kernel The last item to run as middleware
*
* @throws RuntimeException if the stack is seeded more than once
*/
protected function seedMiddlewareStack(callable $kernel = null)
/home/copelibrxp/www/src/Middlewares/TranslatorMiddleware.php
<?php
namespace Application\Middlewares;
class TranslatorMiddleware extends Middleware {
public function __invoke($request, $response, $next) {
$routeInfo = $request->getAttribute('routeInfo');
if (isset($routeInfo[2]) && isset($routeInfo[2]['lang'])) {
$this->container->translator->setLocale($routeInfo[2]['lang']);
$this->container->view->getEnvironment()->addGlobal('lang', $routeInfo[2]['lang']);
}
return $next($request, $response);
}
}
/home/copelibrxp/www/vendor/slim/slim/Slim/DeferredCallable.php
* @return callable|string
*/
public function getCallable()
{
return $this->callable;
}
/**
* @return mixed
*/
public function __invoke()
{
$callable = $this->resolveCallable($this->callable);
if ($callable instanceof Closure) {
$callable = $callable->bindTo($this->container);
}
$args = func_get_args();
return call_user_func_array($callable, $args);
}
}
/home/copelibrxp/www/vendor/slim/slim/Slim/DeferredCallable.php
* @return callable|string
*/
public function getCallable()
{
return $this->callable;
}
/**
* @return mixed
*/
public function __invoke()
{
$callable = $this->resolveCallable($this->callable);
if ($callable instanceof Closure) {
$callable = $callable->bindTo($this->container);
}
$args = func_get_args();
return call_user_func_array($callable, $args);
}
}
/home/copelibrxp/www/vendor/slim/slim/Slim/MiddlewareAwareTrait.php
* @throws UnexpectedValueException If the middleware doesn't return a Psr\Http\Message\ResponseInterface
*/
protected function addMiddleware(callable $callable)
{
if ($this->middlewareLock) {
throw new RuntimeException('Middleware can’t be added once the stack is dequeuing');
}
if (is_null($this->tip)) {
$this->seedMiddlewareStack();
}
$next = $this->tip;
$this->tip = function (
ServerRequestInterface $request,
ResponseInterface $response
) use (
$callable,
$next
) {
$result = call_user_func($callable, $request, $response, $next);
if ($result instanceof ResponseInterface === false) {
throw new UnexpectedValueException(
'Middleware must return instance of \Psr\Http\Message\ResponseInterface'
);
}
return $result;
};
return $this;
}
/**
* Seed middleware stack with first callable
*
* @param callable $kernel The last item to run as middleware
*
* @throws RuntimeException if the stack is seeded more than once
*/
protected function seedMiddlewareStack(callable $kernel = null)
/home/copelibrxp/www/vendor/slim/slim/Slim/MiddlewareAwareTrait.php
* @throws UnexpectedValueException If the middleware doesn't return a Psr\Http\Message\ResponseInterface
*/
protected function addMiddleware(callable $callable)
{
if ($this->middlewareLock) {
throw new RuntimeException('Middleware can’t be added once the stack is dequeuing');
}
if (is_null($this->tip)) {
$this->seedMiddlewareStack();
}
$next = $this->tip;
$this->tip = function (
ServerRequestInterface $request,
ResponseInterface $response
) use (
$callable,
$next
) {
$result = call_user_func($callable, $request, $response, $next);
if ($result instanceof ResponseInterface === false) {
throw new UnexpectedValueException(
'Middleware must return instance of \Psr\Http\Message\ResponseInterface'
);
}
return $result;
};
return $this;
}
/**
* Seed middleware stack with first callable
*
* @param callable $kernel The last item to run as middleware
*
* @throws RuntimeException if the stack is seeded more than once
*/
protected function seedMiddlewareStack(callable $kernel = null)
/home/copelibrxp/www/vendor/slim/slim/Slim/MiddlewareAwareTrait.php
$this->tip = $kernel;
}
/**
* Call middleware stack
*
* @param ServerRequestInterface $request A request object
* @param ResponseInterface $response A response object
*
* @return ResponseInterface
*/
public function callMiddlewareStack(ServerRequestInterface $request, ResponseInterface $response)
{
if (is_null($this->tip)) {
$this->seedMiddlewareStack();
}
/** @var callable $start */
$start = $this->tip;
$this->middlewareLock = true;
$response = $start($request, $response);
$this->middlewareLock = false;
return $response;
}
}
/home/copelibrxp/www/vendor/slim/slim/Slim/App.php
* @throws Exception
* @throws Throwable
*/
public function process(ServerRequestInterface $request, ResponseInterface $response)
{
// Ensure basePath is set
$router = $this->container->get('router');
if (is_callable([$request->getUri(), 'getBasePath']) && is_callable([$router, 'setBasePath'])) {
$router->setBasePath($request->getUri()->getBasePath());
}
// Dispatch the Router first if the setting for this is on
if ($this->container->get('settings')['determineRouteBeforeAppMiddleware'] === true) {
// Dispatch router (note: you won't be able to alter routes after this)
$request = $this->dispatchRouterAndPrepareRoute($request, $router);
}
// Traverse middleware stack
try {
$response = $this->callMiddlewareStack($request, $response);
} catch (Exception $e) {
$response = $this->handleException($e, $request, $response);
} catch (Throwable $e) {
$response = $this->handlePhpError($e, $request, $response);
}
return $response;
}
/**
* Send the response to the client
*
* @param ResponseInterface $response
*/
public function respond(ResponseInterface $response)
{
// Send response
if (!headers_sent()) {
// Headers
foreach ($response->getHeaders() as $name => $values) {
/home/copelibrxp/www/vendor/slim/slim/Slim/App.php
/**
* Run application
*
* This method traverses the application middleware stack and then sends the
* resultant Response object to the HTTP client.
*
* @param bool|false $silent
*
* @return ResponseInterface
*
* @throws Exception
* @throws Throwable
*/
public function run($silent = false)
{
$response = $this->container->get('response');
try {
ob_start();
$response = $this->process($this->container->get('request'), $response);
} catch (InvalidMethodException $e) {
$response = $this->processInvalidMethod($e->getRequest(), $response);
} finally {
$output = ob_get_clean();
}
if (!empty($output) && $response->getBody()->isWritable()) {
$outputBuffering = $this->container->get('settings')['outputBuffering'];
if ($outputBuffering === 'prepend') {
// prepend output buffer content
$body = new Http\Body(fopen('php://temp', 'r+'));
$body->write($output . $response->getBody());
$response = $response->withBody($body);
} elseif ($outputBuffering === 'append') {
// append output buffer content
$response->getBody()->write($output);
}
}
$response = $this->finalize($response);
/home/copelibrxp/www/public/index.php
require __DIR__ . '/../vendor/autoload.php';
session_start();
// Instantiate the app
$settings = require __DIR__ . '/../src/settings.php';
$app = new \Slim\App($settings);
// Set up dependencies
require __DIR__ . '/../src/dependencies.php';
// Register middleware
require __DIR__ . '/../src/middleware.php';
// Register routes
require __DIR__ . '/../src/routes.php';
// Run app
$app->run();