Upgrade to 3.0.3

This commit is contained in:
Bastian Allgeier
2019-03-05 10:55:03 +01:00
parent 8e3d86a590
commit 418db4b09b
40 changed files with 704 additions and 144 deletions

View File

@@ -107,6 +107,9 @@ class App
'users'
]);
// set the singleton
Model::$kirby = static::$instance = $this;
// setup the I18n class with the translation loader
$this->i18n();
@@ -120,9 +123,6 @@ class App
// handle those damn errors
$this->handleErrors();
// set the singleton
Model::$kirby = static::$instance = $this;
// bake config
Config::$data = $this->options;
}
@@ -226,15 +226,17 @@ class App
*/
public function call(string $path = null, string $method = null)
{
$path = $path ?? $this->path();
$method = $method ?? $this->request()->method();
$route = $this->router()->find($path, $method);
$router = $this->router();
$this->trigger('route:before', $route, $path, $method);
$result = $route->action()->call($route, ...$route->arguments());
$this->trigger('route:after', $route, $path, $method, $result);
$router::$beforeEach = function ($route, $path, $method) {
$this->trigger('route:before', $route, $path, $method);
};
return $result;
$router::$afterEach = function ($route, $path, $method, $result) {
$this->trigger('route:after', $route, $path, $method, $result);
};
return $router->call($path ?? $this->path(), $method ?? $this->request()->method());
}
/**
@@ -807,33 +809,32 @@ class App
// the site is needed a couple times here
$site = $this->site();
// use the home page
if ($path === null) {
return $site->homePage();
}
if ($page = $site->find($path)) {
return $page;
}
// search for the page by path
$page = $site->find($path);
if ($draft = $site->draft($path)) {
// search for a draft if the page cannot be found
if (!$page && $draft = $site->draft($path)) {
if ($this->user() || $draft->isVerified(get('token'))) {
return $draft;
$page = $draft;
}
}
// try to resolve content representations if the path has an extension
$extension = F::extension($path);
// remove the extension from the path
$path = Str::rtrim($path, '.' . $extension);
// stop when there's no extension
// no content representation? then return the page
if (empty($extension) === true) {
return null;
return $page;
}
// try to find the page for the representation
if ($page = $site->find($path)) {
// only try to return a representation
// when the page has been found
if ($page) {
try {
return $this
->response()
@@ -845,7 +846,7 @@ class App
}
$id = dirname($path);
$filename = basename($path) . '.' . $extension;
$filename = basename($path);
// try to resolve image urls for pages and drafts
if ($page = $site->findPageOrDraft($id)) {