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

@@ -17,128 +17,128 @@ use Kirby\Toolkit\Str;
*/
class LayoutColumn extends Item
{
use HasMethods;
use HasMethods;
public const ITEMS_CLASS = '\Kirby\Cms\LayoutColumns';
public const ITEMS_CLASS = '\Kirby\Cms\LayoutColumns';
/**
* @var \Kirby\Cms\Blocks
*/
protected $blocks;
/**
* @var \Kirby\Cms\Blocks
*/
protected $blocks;
/**
* @var string
*/
protected $width;
/**
* @var string
*/
protected $width;
/**
* Creates a new LayoutColumn object
*
* @param array $params
*/
public function __construct(array $params = [])
{
parent::__construct($params);
/**
* Creates a new LayoutColumn object
*
* @param array $params
*/
public function __construct(array $params = [])
{
parent::__construct($params);
$this->blocks = Blocks::factory($params['blocks'] ?? [], [
'parent' => $this->parent
]);
$this->blocks = Blocks::factory($params['blocks'] ?? [], [
'parent' => $this->parent
]);
$this->width = $params['width'] ?? '1/1';
}
$this->width = $params['width'] ?? '1/1';
}
/**
* Magic getter function
*
* @param string $method
* @param mixed $args
* @return mixed
*/
public function __call(string $method, $args)
{
// layout column methods
if ($this->hasMethod($method) === true) {
return $this->callMethod($method, $args);
}
}
/**
* Magic getter function
*
* @param string $method
* @param mixed $args
* @return mixed
*/
public function __call(string $method, $args)
{
// layout column methods
if ($this->hasMethod($method) === true) {
return $this->callMethod($method, $args);
}
}
/**
* Returns the blocks collection
*
* @param bool $includeHidden Sets whether to include hidden blocks
* @return \Kirby\Cms\Blocks
*/
public function blocks(bool $includeHidden = false)
{
if ($includeHidden === false) {
return $this->blocks->filter('isHidden', false);
}
/**
* Returns the blocks collection
*
* @param bool $includeHidden Sets whether to include hidden blocks
* @return \Kirby\Cms\Blocks
*/
public function blocks(bool $includeHidden = false)
{
if ($includeHidden === false) {
return $this->blocks->filter('isHidden', false);
}
return $this->blocks;
}
return $this->blocks;
}
/**
* Checks if the column is empty
* @since 3.5.2
*
* @return bool
*/
public function isEmpty(): bool
{
return $this
->blocks()
->filter('isHidden', false)
->count() === 0;
}
/**
* Checks if the column is empty
* @since 3.5.2
*
* @return bool
*/
public function isEmpty(): bool
{
return $this
->blocks()
->filter('isHidden', false)
->count() === 0;
}
/**
* Checks if the column is not empty
* @since 3.5.2
*
* @return bool
*/
public function isNotEmpty(): bool
{
return $this->isEmpty() === false;
}
/**
* Checks if the column is not empty
* @since 3.5.2
*
* @return bool
*/
public function isNotEmpty(): bool
{
return $this->isEmpty() === false;
}
/**
* Returns the number of columns this column spans
*
* @param int $columns
* @return int
*/
public function span(int $columns = 12): int
{
$fraction = Str::split($this->width, '/');
$a = $fraction[0] ?? 1;
$b = $fraction[1] ?? 1;
/**
* Returns the number of columns this column spans
*
* @param int $columns
* @return int
*/
public function span(int $columns = 12): int
{
$fraction = Str::split($this->width, '/');
$a = $fraction[0] ?? 1;
$b = $fraction[1] ?? 1;
return $columns * $a / $b;
}
return $columns * $a / $b;
}
/**
* The result is being sent to the editor
* via the API in the panel
*
* @return array
*/
public function toArray(): array
{
return [
'blocks' => $this->blocks(true)->toArray(),
'id' => $this->id(),
'width' => $this->width(),
];
}
/**
* The result is being sent to the editor
* via the API in the panel
*
* @return array
*/
public function toArray(): array
{
return [
'blocks' => $this->blocks(true)->toArray(),
'id' => $this->id(),
'width' => $this->width(),
];
}
/**
* Returns the width of the column
*
* @return string
*/
public function width(): string
{
return $this->width;
}
/**
* Returns the width of the column
*
* @return string
*/
public function width(): string
{
return $this->width;
}
}