Upgrade to 3.7.1

This commit is contained in:
Bastian Allgeier
2022-07-12 13:33:21 +02:00
parent 7931eb5e47
commit 1ad1eaf387
377 changed files with 63981 additions and 63824 deletions

View File

@@ -20,45 +20,47 @@ use Kirby\Exception\InvalidArgumentException;
*/
class Structure extends Collection
{
/**
* Creates a new Collection with the given objects
*
* @param array $objects Kirby\Cms\StructureObject` objects or props arrays
* @param object|null $parent
*/
public function __construct($objects = [], $parent = null)
{
$this->parent = $parent;
$this->set($objects);
}
/**
* Creates a new Collection with the given objects
*
* @param array $objects Kirby\Cms\StructureObject` objects or props arrays
* @param object|null $parent
*/
public function __construct($objects = [], $parent = null)
{
$this->parent = $parent;
$this->set($objects);
}
/**
* The internal setter for collection items.
* This makes sure that nothing unexpected ends
* up in the collection. You can pass arrays or
* StructureObjects
*
* @param string $id
* @param array|StructureObject $props
* @throws \Kirby\Exception\InvalidArgumentException
*/
public function __set(string $id, $props)
{
if (is_a($props, 'Kirby\Cms\StructureObject') === true) {
$object = $props;
} else {
if (is_array($props) === false) {
throw new InvalidArgumentException('Invalid structure data');
}
/**
* The internal setter for collection items.
* This makes sure that nothing unexpected ends
* up in the collection. You can pass arrays or
* StructureObjects
*
* @param string $id
* @param array|StructureObject $props
* @return void
*
* @throws \Kirby\Exception\InvalidArgumentException
*/
public function __set(string $id, $props): void
{
if (is_a($props, 'Kirby\Cms\StructureObject') === true) {
$object = $props;
} else {
if (is_array($props) === false) {
throw new InvalidArgumentException('Invalid structure data');
}
$object = new StructureObject([
'content' => $props,
'id' => $props['id'] ?? $id,
'parent' => $this->parent,
'structure' => $this
]);
}
$object = new StructureObject([
'content' => $props,
'id' => $props['id'] ?? $id,
'parent' => $this->parent,
'structure' => $this
]);
}
return parent::__set($object->id(), $object);
}
parent::__set($object->id(), $object);
}
}