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

@@ -16,92 +16,92 @@ use Kirby\Toolkit\Component;
*/
class Section extends Component
{
/**
* Registry for all component mixins
*
* @var array
*/
public static $mixins = [];
/**
* Registry for all component mixins
*
* @var array
*/
public static $mixins = [];
/**
* Registry for all component types
*
* @var array
*/
public static $types = [];
/**
* Registry for all component types
*
* @var array
*/
public static $types = [];
/**
* Section constructor.
*
* @param string $type
* @param array $attrs
* @throws \Kirby\Exception\InvalidArgumentException
*/
public function __construct(string $type, array $attrs = [])
{
if (isset($attrs['model']) === false) {
throw new InvalidArgumentException('Undefined section model');
}
/**
* Section constructor.
*
* @param string $type
* @param array $attrs
* @throws \Kirby\Exception\InvalidArgumentException
*/
public function __construct(string $type, array $attrs = [])
{
if (isset($attrs['model']) === false) {
throw new InvalidArgumentException('Undefined section model');
}
if (is_a($attrs['model'], 'Kirby\Cms\Model') === false) {
throw new InvalidArgumentException('Invalid section model');
}
if (is_a($attrs['model'], 'Kirby\Cms\Model') === false) {
throw new InvalidArgumentException('Invalid section model');
}
// use the type as fallback for the name
$attrs['name'] ??= $type;
$attrs['type'] = $type;
// use the type as fallback for the name
$attrs['name'] ??= $type;
$attrs['type'] = $type;
parent::__construct($type, $attrs);
}
parent::__construct($type, $attrs);
}
public function errors(): array
{
if (array_key_exists('errors', $this->methods) === true) {
return $this->methods['errors']->call($this);
}
public function errors(): array
{
if (array_key_exists('errors', $this->methods) === true) {
return $this->methods['errors']->call($this);
}
return $this->errors ?? [];
}
return $this->errors ?? [];
}
/**
* @return \Kirby\Cms\App
*/
public function kirby()
{
return $this->model()->kirby();
}
/**
* @return \Kirby\Cms\App
*/
public function kirby()
{
return $this->model()->kirby();
}
/**
* @return \Kirby\Cms\Model
*/
public function model()
{
return $this->model;
}
/**
* @return \Kirby\Cms\Model
*/
public function model()
{
return $this->model;
}
/**
* @return array
*/
public function toArray(): array
{
$array = parent::toArray();
/**
* @return array
*/
public function toArray(): array
{
$array = parent::toArray();
unset($array['model']);
unset($array['model']);
return $array;
}
return $array;
}
/**
* @return array
*/
public function toResponse(): array
{
return array_merge([
'status' => 'ok',
'code' => 200,
'name' => $this->name,
'type' => $this->type
], $this->toArray());
}
/**
* @return array
*/
public function toResponse(): array
{
return array_merge([
'status' => 'ok',
'code' => 200,
'name' => $this->name,
'type' => $this->type
], $this->toArray());
}
}