/var/www/vhosts/ihelp.ro/_OLD/vendor/cakephp/cakephp/src/Http
Edit: /var/www/vhosts/ihelp.ro/_OLD/vendor/cakephp/cakephp/src/Http/BaseApplication.php (7409B)
configDir = rtrim($configDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
$this->plugins = Plugin::getCollection();
$this->_eventManager = $eventManager ?: EventManager::instance();
$this->controllerFactory = $controllerFactory;
}
/**
* @param \Cake\Http\MiddlewareQueue $middlewareQueue The middleware queue to set in your App Class
* @return \Cake\Http\MiddlewareQueue
*/
abstract public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue;
/**
* @inheritDoc
*/
public function pluginMiddleware(MiddlewareQueue $middleware): MiddlewareQueue
{
foreach ($this->plugins->with('middleware') as $plugin) {
$middleware = $plugin->middleware($middleware);
}
return $middleware;
}
/**
* @inheritDoc
*/
public function addPlugin($name, array $config = [])
{
if (is_string($name)) {
$plugin = $this->plugins->create($name, $config);
} else {
$plugin = $name;
}
$this->plugins->add($plugin);
return $this;
}
/**
* Add an optional plugin
*
* If it isn't available, ignore it.
*
* @param string|\Cake\Core\PluginInterface $name The plugin name or plugin object.
* @param array $config The configuration data for the plugin if using a string for $name
* @return $this
*/
public function addOptionalPlugin($name, array $config = [])
{
try {
$this->addPlugin($name, $config);
} catch (MissingPluginException $e) {
// Do not halt if the plugin is missing
}
return $this;
}
/**
* Get the plugin collection in use.
*
* @return \Cake\Core\PluginCollection
*/
public function getPlugins(): PluginCollection
{
return $this->plugins;
}
/**
* @inheritDoc
*/
public function bootstrap(): void
{
require_once $this->configDir . 'bootstrap.php';
}
/**
* @inheritDoc
*/
public function pluginBootstrap(): void
{
foreach ($this->plugins->with('bootstrap') as $plugin) {
$plugin->bootstrap($this);
}
}
/**
* {@inheritDoc}
*
* By default this will load `config/routes.php` for ease of use and backwards compatibility.
*
* @param \Cake\Routing\RouteBuilder $routes A route builder to add routes into.
* @return void
*/
public function routes(RouteBuilder $routes): void
{
// Only load routes if the router is empty
if (!Router::routes()) {
require $this->configDir . 'routes.php';
}
}
/**
* @inheritDoc
*/
public function pluginRoutes(RouteBuilder $routes): RouteBuilder
{
foreach ($this->plugins->with('routes') as $plugin) {
$plugin->routes($routes);
}
return $routes;
}
/**
* Define the console commands for an application.
*
* By default all commands in CakePHP, plugins and the application will be
* loaded using conventions based names.
*
* @param \Cake\Console\CommandCollection $commands The CommandCollection to add commands into.
* @return \Cake\Console\CommandCollection The updated collection.
*/
public function console(CommandCollection $commands): CommandCollection
{
return $commands->addMany($commands->autoDiscover());
}
/**
* @inheritDoc
*/
public function pluginConsole(CommandCollection $commands): CommandCollection
{
foreach ($this->plugins->with('console') as $plugin) {
$commands = $plugin->console($commands);
}
return $commands;
}
/**
* Invoke the application.
*
* - Convert the PSR response into CakePHP equivalents.
* - Create the controller that will handle this request.
* - Invoke the controller.
*
* @param \Psr\Http\Message\ServerRequestInterface $request The request
* @return \Psr\Http\Message\ResponseInterface
*/
public function handle(
ServerRequestInterface $request
): ResponseInterface {
if ($this->controllerFactory === null) {
$this->controllerFactory = new ControllerFactory();
}
if (Router::getRequest() !== $request) {
Router::setRequest($request);
}
$controller = $this->controllerFactory->create($request);
return $this->controllerFactory->invoke($controller);
}
}