Upgrade to 3.4.3
This commit is contained in:
@@ -4,7 +4,6 @@ namespace Kirby\Cms;
|
||||
|
||||
use Closure;
|
||||
use Kirby\Exception\DuplicateException;
|
||||
use Kirby\Exception\Exception;
|
||||
use Kirby\Exception\InvalidArgumentException;
|
||||
use Kirby\Exception\LogicException;
|
||||
use Kirby\Exception\NotFoundException;
|
||||
@@ -28,8 +27,9 @@ trait PageActions
|
||||
* The sorting number must already be correct
|
||||
* when the method is called
|
||||
*
|
||||
* @param int $num
|
||||
* @param int|null $num
|
||||
* @return self
|
||||
* @throws \Kirby\Exception\LogicException If a draft is being sorted or the directory cannot be moved
|
||||
*/
|
||||
public function changeNum(int $num = null)
|
||||
{
|
||||
@@ -74,8 +74,9 @@ trait PageActions
|
||||
* Changes the slug/uid of the page
|
||||
*
|
||||
* @param string $slug
|
||||
* @param string $languageCode
|
||||
* @param string|null $languageCode
|
||||
* @return self
|
||||
* @throws \Kirby\Exception\LogicException If the directory cannot be moved
|
||||
*/
|
||||
public function changeSlug(string $slug, string $languageCode = null)
|
||||
{
|
||||
@@ -137,8 +138,10 @@ trait PageActions
|
||||
* Change the slug for a specific language
|
||||
*
|
||||
* @param string $slug
|
||||
* @param string $languageCode
|
||||
* @param string|null $languageCode
|
||||
* @return self
|
||||
* @throws \Kirby\Exception\NotFoundException If the language for the given language code cannot be found
|
||||
* @throws \Kirby\Exception\InvalidArgumentException If the slug for the default language is being changed
|
||||
*/
|
||||
protected function changeSlugForLanguage(string $slug, string $languageCode = null)
|
||||
{
|
||||
@@ -168,8 +171,9 @@ trait PageActions
|
||||
* to either draft, listed or unlisted
|
||||
*
|
||||
* @param string $status "draft", "listed" or "unlisted"
|
||||
* @param int $position Optional sorting number
|
||||
* @param int|null $position Optional sorting number
|
||||
* @return self
|
||||
* @throws \Kirby\Exception\InvalidArgumentException If an invalid status is being passed
|
||||
*/
|
||||
public function changeStatus(string $status, int $position = null)
|
||||
{
|
||||
@@ -181,10 +185,13 @@ trait PageActions
|
||||
case 'unlisted':
|
||||
return $this->changeStatusToUnlisted();
|
||||
default:
|
||||
throw new Exception('Invalid status: ' . $status);
|
||||
throw new InvalidArgumentException('Invalid status: ' . $status);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return self
|
||||
*/
|
||||
protected function changeStatusToDraft()
|
||||
{
|
||||
$arguments = ['page' => $this, 'status' => 'draft', 'position' => null];
|
||||
@@ -245,6 +252,7 @@ trait PageActions
|
||||
*
|
||||
* @param string $template
|
||||
* @return self
|
||||
* @throws \Kirby\Exception\LogicException If the textfile cannot be renamed/moved
|
||||
*/
|
||||
public function changeTemplate(string $template)
|
||||
{
|
||||
@@ -312,7 +320,7 @@ trait PageActions
|
||||
*
|
||||
* @param string $action
|
||||
* @param array $arguments
|
||||
* @param Closure $callback
|
||||
* @param \Closure $callback
|
||||
* @return mixed
|
||||
*/
|
||||
protected function commit(string $action, array $arguments, Closure $callback)
|
||||
@@ -346,6 +354,7 @@ trait PageActions
|
||||
*
|
||||
* @param array $options
|
||||
* @return \Kirby\Cms\Page
|
||||
* @throws \Kirby\Exception\DuplicateException If the page already exists
|
||||
*/
|
||||
public function copy(array $options = [])
|
||||
{
|
||||
@@ -491,7 +500,7 @@ trait PageActions
|
||||
* Create the sorting number for the page
|
||||
* depending on the blueprint settings
|
||||
*
|
||||
* @param int $num
|
||||
* @param int|null $num
|
||||
* @return int
|
||||
*/
|
||||
public function createNum(int $num = null): int
|
||||
@@ -604,7 +613,7 @@ trait PageActions
|
||||
* Duplicates the page with the given
|
||||
* slug and optionally copies all files
|
||||
*
|
||||
* @param string $slug
|
||||
* @param string|null $slug
|
||||
* @param array $options
|
||||
* @return \Kirby\Cms\Page
|
||||
*/
|
||||
@@ -626,6 +635,10 @@ trait PageActions
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return self
|
||||
* @throws \Kirby\Exception\LogicException If the folder cannot be moved
|
||||
*/
|
||||
public function publish()
|
||||
{
|
||||
if ($this->isDraft() === false) {
|
||||
@@ -676,6 +689,11 @@ trait PageActions
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $position
|
||||
* @return bool
|
||||
* @throws \Kirby\Exception\LogicException If the page is not included in the siblings collection
|
||||
*/
|
||||
protected function resortSiblingsAfterListing(int $position = null): bool
|
||||
{
|
||||
// get all siblings including the current page
|
||||
@@ -722,6 +740,9 @@ trait PageActions
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function resortSiblingsAfterUnlisting(): bool
|
||||
{
|
||||
$index = 0;
|
||||
@@ -746,6 +767,10 @@ trait PageActions
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $position
|
||||
* @return self
|
||||
*/
|
||||
public function sort($position = null)
|
||||
{
|
||||
return $this->changeStatus('listed', $position);
|
||||
@@ -756,6 +781,7 @@ trait PageActions
|
||||
* unlisted to draft.
|
||||
*
|
||||
* @return self
|
||||
* @throws \Kirby\Exception\LogicException If the folder cannot be moved
|
||||
*/
|
||||
public function unpublish()
|
||||
{
|
||||
@@ -789,8 +815,8 @@ trait PageActions
|
||||
/**
|
||||
* Updates the page data
|
||||
*
|
||||
* @param array $input
|
||||
* @param string $language
|
||||
* @param array|null $input
|
||||
* @param string|null $language
|
||||
* @param bool $validate
|
||||
* @return self
|
||||
*/
|
||||
|
Reference in New Issue
Block a user