Files
hocusfokus-web/kirby/src/Cms/PageSiblings.php
Bastian Allgeier eb29ef6d6c Upgrade to 3.1.2
2019-04-09 14:34:12 +02:00

189 lines
3.8 KiB
PHP
Executable File

<?php
namespace Kirby\Cms;
trait PageSiblings
{
/**
* @deprecated 3.0.0 Use `Page::hasNextUnlisted` instead
* @return boolean
*/
public function hasNextInvisible(): bool
{
return $this->hasNextUnlisted();
}
/**
* Checks if there's a next listed
* page in the siblings collection
*
* @return bool
*/
public function hasNextListed(): bool
{
return $this->nextListed() !== null;
}
/**
* @deprecated 3.0.0 Use `Page::hasNextListed` instead
* @return boolean
*/
public function hasNextVisible(): bool
{
return $this->hasNextListed();
}
/**
* Checks if there's a next unlisted
* page in the siblings collection
*
* @return bool
*/
public function hasNextUnlisted(): bool
{
return $this->nextUnlisted() !== null;
}
/**
* @deprecated 3.0.0 Use `Page::hasPrevUnlisted` instead
* @return boolean
*/
public function hasPrevInvisible(): bool
{
return $this->hasPrevUnlisted();
}
/**
* Checks if there's a previous listed
* page in the siblings collection
*
* @return bool
*/
public function hasPrevListed(): bool
{
return $this->prevListed() !== null;
}
/**
* Checks if there's a previous unlisted
* page in the siblings collection
*
* @return bool
*/
public function hasPrevUnlisted(): bool
{
return $this->prevUnlisted() !== null;
}
/**
* @deprecated 3.0.0 Use `Page::hasPrevListed instead`
* @return boolean
*/
public function hasPrevVisible(): bool
{
return $this->hasPrevListed();
}
/**
* @deprecated 3.0.0 Use `Page::nextUnlisted()` instead
* @return self|null
*/
public function nextInvisible()
{
return $this->nextUnlisted();
}
/**
* Returns the next listed page if it exists
*
* @return self|null
*/
public function nextListed()
{
return $this->nextAll()->listed()->first();
}
/**
* Returns the next unlisted page if it exists
*
* @return self|null
*/
public function nextUnlisted()
{
return $this->nextAll()->unlisted()->first();
}
/**
* @deprecated 3.0.0 Use `Page::prevListed()` instead
* @return self|null
*/
public function nextVisible()
{
return $this->nextListed();
}
/**
* @deprecated 3.0.0 Use `Page::prevUnlisted()` instead
* @return self|null
*/
public function prevInvisible()
{
return $this->prevUnlisted();
}
/**
* Returns the previous listed page
*
* @return self|null
*/
public function prevListed()
{
return $this->prevAll()->listed()->last();
}
/**
* Returns the previous unlisted page
*
* @return self|null
*/
public function prevUnlisted()
{
return $this->prevAll()->unlisted()->first();
}
/**
* @deprecated 3.0.0 Use `Page::prevListed()` instead
* @return self|null
*/
public function prevVisible()
{
return $this->prevListed();
}
/**
* Private siblings collector
*
* @return Collection
*/
protected function siblingsCollection()
{
if ($this->isDraft() === true) {
return $this->parentModel()->drafts();
} else {
return $this->parentModel()->children();
}
}
/**
* Returns siblings with the same template
*
* @param bool $self
* @return self
*/
public function templateSiblings(bool $self = true)
{
return $this->siblings($self)->filterBy('intendedTemplate', $this->intendedTemplate()->name());
}
}