Update Composer packages
This commit is contained in:
parent
0320235f6c
commit
a8b68fb61b
378 changed files with 28466 additions and 28852 deletions
53
kirby/src/Uuid/PageUuid.php
Normal file
53
kirby/src/Uuid/PageUuid.php
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Uuid;
|
||||
|
||||
use Generator;
|
||||
use Kirby\Cms\App;
|
||||
use Kirby\Cms\Page;
|
||||
|
||||
/**
|
||||
* UUID for \Kirby\Cms\Page
|
||||
* @since 3.8.0
|
||||
*
|
||||
* @package Kirby Uuid
|
||||
* @author Nico Hoffmann <nico@getkirby.com>
|
||||
* @link https://getkirby.com
|
||||
* @copyright Bastian Allgeier
|
||||
* @license https://getkirby.com/license
|
||||
*/
|
||||
class PageUuid extends ModelUuid
|
||||
{
|
||||
protected const TYPE = 'page';
|
||||
|
||||
/**
|
||||
* @var \Kirby\Cms\Page|null
|
||||
*/
|
||||
public Identifiable|null $model;
|
||||
|
||||
/**
|
||||
* Looks up UUID in cache and resolves
|
||||
* to page object
|
||||
*/
|
||||
protected function findByCache(): Page|null
|
||||
{
|
||||
$key = $this->key();
|
||||
$value = Uuids::cache()->get($key);
|
||||
return App::instance()->page($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generator for all pages and drafts in the site
|
||||
*
|
||||
* @return \Generator|\Kirby\Cms\Page[]
|
||||
*/
|
||||
public static function index(Page|null $entry = null): Generator
|
||||
{
|
||||
$entry ??= App::instance()->site();
|
||||
|
||||
foreach ($entry->childrenAndDrafts() as $page) {
|
||||
yield $page;
|
||||
yield from static::index($page);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue