Files
lichterei-web/kirby/src/Uuid/HasUuids.php
Bastian Allgeier 7d168aae58 Upgrade to 3.8.0
2022-10-06 10:11:54 +02:00

33 lines
640 B
PHP

<?php
namespace Kirby\Uuid;
/**
* Adds UUID lookup to collections
*
* @package Kirby Cms
* @author Nico Hoffmann <nico@getkirby.com>
* @link https://getkirby.com
* @copyright Bastian Allgeier
* @license https://getkirby.com/license
*/
trait HasUuids
{
/**
* Find a single element by global UUID
* @since 3.8.0
*/
protected function findByUuid(
string $uuid,
string|null $scheme = null
): Identifiable|null {
if (Uuid::is($uuid, $scheme) === true) {
// look up model by UUID while prioritizing
// $this collection when searching
return Uuid::for($uuid, $this)->model();
}
return null;
}
}