Initial commit

This commit is contained in:
isUnknown 2025-10-03 07:46:23 +02:00
commit efa5624dab
687 changed files with 162710 additions and 0 deletions

View file

@ -0,0 +1,54 @@
<?php
namespace Kirby\Template;
use Countable;
/**
* The slots collection is simplifying
* slot access. Slots can be accessed with
* `$slots->heading()` and accessing a non-existing
* slot will simply return null.
*
* @package Kirby Template
* @author Bastian Allgeier <bastian@getkirby.com>
* @link https://getkirby.com
* @copyright Bastian Allgeier
* @license https://getkirby.com/license
*/
class Slots implements Countable
{
/**
* Creates a new slots collection
*/
public function __construct(
protected array $slots
) {
}
/**
* Magic getter for slots;
* e.g. `$slots->heading`
*/
public function __get(string $name): Slot|null
{
return $this->slots[$name] ?? null;
}
/**
* Magic getter method for slots;
* e.g. `$slots->heading()`
*/
public function __call(string $name, array $args): Slot|null
{
return $this->__get($name);
}
/**
* Counts the number of defined slots
*/
public function count(): int
{
return count($this->slots);
}
}