Update Kirby and Composer dependencies

This commit is contained in:
Paul Nicoué 2022-03-22 15:39:39 +01:00
parent f5d3ea5e84
commit ec74d78ba9
382 changed files with 25077 additions and 4955 deletions

View file

@ -33,13 +33,11 @@ use Throwable;
* @package Kirby Cms
* @author Bastian Allgeier <bastian@getkirby.com>
* @link https://getkirby.com
* @copyright Bastian Allgeier GmbH
* @copyright Bastian Allgeier
* @license https://getkirby.com/license
*/
class App
{
const CLASS_ALIAS = 'kirby';
use AppCaches;
use AppErrors;
use AppPlugins;
@ -47,6 +45,8 @@ class App
use AppUsers;
use Properties;
public const CLASS_ALIAS = 'kirby';
protected static $instance;
protected static $version;
@ -56,6 +56,7 @@ class App
protected $collections;
protected $core;
protected $defaultLanguage;
protected $environment;
protected $language;
protected $languages;
protected $locks;
@ -91,12 +92,17 @@ class App
// register all roots to be able to load stuff afterwards
$this->bakeRoots($props['roots'] ?? []);
// stuff from config and additional options
$this->optionsFromConfig();
$this->optionsFromProps($props['options'] ?? []);
// register the Whoops error handler
$this->handleErrors();
try {
// stuff from config and additional options
$this->optionsFromConfig();
$this->optionsFromProps($props['options'] ?? []);
$this->optionsFromEnvironment();
} finally {
// register the Whoops error handler inside of a
// try-finally block to ensure it's still registered
// even if there is a problem loading the configurations
$this->handleErrors();
}
// set the path to make it available for the url bakery
$this->setPath($props['path'] ?? null);
@ -282,11 +288,6 @@ class App
*/
protected function bakeUrls(array $urls = null)
{
// inject the index URL from the config
if (isset($this->options['url']) === true) {
$urls['index'] = $this->options['url'];
}
$urls = array_merge($this->core->urls(), (array)$urls);
$this->urls = Ingredients::bake($urls);
return $this;
@ -330,6 +331,10 @@ class App
{
$router = $this->router();
/**
* @todo Closures should not defined statically but
* for each instance to avoid this constant setting and unsetting
*/
$router::$beforeEach = function ($route, $path, $method) {
$this->trigger('route:before', compact('route', 'path', 'method'));
};
@ -338,7 +343,12 @@ class App
return $this->apply('route:after', compact('route', 'path', 'method', 'result', 'final'), 'result');
};
return $router->call($path ?? $this->path(), $method ?? $this->request()->method());
$result = $router->call($path ?? $this->path(), $method ?? $this->request()->method());
$router::$beforeEach = null;
$router::$afterEach = null;
return $result;
}
/**
@ -580,6 +590,17 @@ class App
return ($this->component('email'))($this, $props, $debug);
}
/**
* Returns the environment object with access
* to the detected host, base url and dedicated options
*
* @return \Kirby\Cms\Environment
*/
public function environment()
{
return $this->environment;
}
/**
* Finds any file in the content directory
*
@ -762,10 +783,11 @@ class App
*/
public function kirbytags(string $text = null, array $data = []): string
{
$data['kirby'] = $data['kirby'] ?? $this;
$data['site'] = $data['site'] ?? $data['kirby']->site();
$data['parent'] = $data['parent'] ?? $data['site']->page();
$options = $this->options;
$data['kirby'] ??= $this;
$data['site'] ??= $data['kirby']->site();
$data['parent'] ??= $data['site']->page();
$options = $this->options;
$text = $this->apply('kirbytags:before', compact('text', 'data', 'options'), 'text');
$text = KirbyTags::parse($text, $data, $options);
@ -780,14 +802,23 @@ class App
* @internal
* @param string|null $text
* @param array $data
* @param bool $inline
* @param bool $inline (deprecated: use $data['markdown']['inline'] instead)
* @return string
* @todo add deprecation warning for $inline parameter in 3.7.0
* @todo rename $data parameter to $options in 3.7.0
* @todo remove $inline parameter in in 3.8.0
*/
public function kirbytext(string $text = null, array $data = [], bool $inline = false): string
{
$options = A::merge([
'markdown' => [
'inline' => $inline
]
], $data);
$text = $this->apply('kirbytext:before', compact('text'), 'text');
$text = $this->kirbytags($text, $data);
$text = $this->markdown($text, $inline);
$text = $this->kirbytags($text, $options);
$text = $this->markdown($text, $options['markdown']);
if ($this->option('smartypants', false) !== false) {
$text = $this->smartypants($text);
@ -881,12 +912,34 @@ class App
*
* @internal
* @param string|null $text
* @param bool $inline
* @param bool|array $options
* @return string
* @todo rename $inline parameter to $options in 3.7.0
* @todo add deprecation warning for boolean $options in 3.7.0
* @todo remove boolean $options in in 3.8.0
*/
public function markdown(string $text = null, bool $inline = false): string
public function markdown(string $text = null, $inline = null): string
{
return ($this->component('markdown'))($this, $text, $this->options['markdown'] ?? [], $inline);
// TODO: remove after renaming parameter
$options = $inline;
// support for the old syntax to enable inline mode as second argument
if (is_bool($options) === true) {
$options = [
'inline' => $options
];
}
// merge global options with local options
$options = array_merge(
$this->options['markdown'] ?? [],
(array)$options
);
// TODO: deprecate passing the $inline parameter in 3.7.0
// TODO: remove passing the $inline parameter in 3.8.0
$inline = $options['inline'] ?? false;
return ($this->component('markdown'))($this, $text, $options, $inline);
}
/**
@ -944,18 +997,30 @@ class App
*/
protected function optionsFromConfig(): array
{
$server = $this->server();
$root = $this->root('config');
// create an empty config container
Config::$data = [];
$main = F::load($root . '/config.php', []);
$host = F::load($root . '/config.' . basename($server->host()) . '.php', []);
$addr = F::load($root . '/config.' . basename($server->address()) . '.php', []);
// load the main config options
$root = $this->root('config');
$options = F::load($root . '/config.php', []);
$config = Config::$data;
// merge into one clean options array
return $this->options = array_replace_recursive(Config::$data, $options);
}
return $this->options = array_replace_recursive($config, $main, $host, $addr);
/**
* Load all options for the current
* server environment
*
* @return array
*/
protected function optionsFromEnvironment(): array
{
// create the environment based on the URL setup
$this->environment = new Environment($this->root('config'), $this->options['url'] ?? null);
// merge into one clean options array
return $this->options = array_replace_recursive($this->options, $this->environment->options());
}
/**
@ -966,7 +1031,10 @@ class App
*/
protected function optionsFromProps(array $options = []): array
{
return $this->options = array_replace_recursive($this->options, $options);
return $this->options = array_replace_recursive(
$this->options,
$options
);
}
/**
@ -1373,7 +1441,7 @@ class App
*/
public function server()
{
return $this->server = $this->server ?? new Server();
return $this->server ??= new Server();
}
/**