Upgrade to 3.6.0

This commit is contained in:
Bastian Allgeier
2021-11-16 14:53:37 +01:00
parent 7388fa4d24
commit 92b7a330fa
318 changed files with 20017 additions and 6878 deletions

View File

@@ -169,26 +169,12 @@ class PageRules
return true;
}
if ($page->permissions()->changeStatus() !== true) {
throw new PermissionException([
'key' => 'page.changeStatus.permission',
'data' => [
'slug' => $page->slug()
]
]);
}
static::publish($page);
if ($position !== null && $position < 0) {
throw new InvalidArgumentException(['key' => 'page.num.invalid']);
}
if ($page->isDraft() === true && empty($page->errors()) === false) {
throw new PermissionException([
'key' => 'page.changeStatus.incomplete',
'details' => $page->errors()
]);
}
return true;
}
@@ -201,14 +187,7 @@ class PageRules
*/
public static function changeStatusToUnlisted(Page $page)
{
if ($page->permissions()->changeStatus() !== true) {
throw new PermissionException([
'key' => 'page.changeStatus.permission',
'data' => [
'slug' => $page->slug()
]
]);
}
static::publish($page);
return true;
}
@@ -376,6 +355,34 @@ class PageRules
return true;
}
/**
* Check if the page can be published
* (status change from draft to listed or unlisted)
*
* @param Page $page
* @return bool
*/
public static function publish(Page $page): bool
{
if ($page->permissions()->changeStatus() !== true) {
throw new PermissionException([
'key' => 'page.changeStatus.permission',
'data' => [
'slug' => $page->slug()
]
]);
}
if ($page->isDraft() === true && empty($page->errors()) === false) {
throw new PermissionException([
'key' => 'page.changeStatus.incomplete',
'details' => $page->errors()
]);
}
return true;
}
/**
* Validates if the page can be updated
*