Add blueprints and fake content

This commit is contained in:
Paul Nicoué 2021-11-18 17:44:47 +01:00
parent 1ff19bf38f
commit 8235816462
592 changed files with 22385 additions and 31535 deletions

View file

@ -41,6 +41,18 @@ class Layouts extends Items
return parent::factory($items, $params);
}
/**
* Checks if a given block type exists in the layouts collection
* @since 3.6.0
*
* @param string $type
* @return bool
*/
public function hasBlockType(string $type): bool
{
return $this->toBlocks()->hasType($type);
}
/**
* Parse layouts data
*
@ -63,4 +75,28 @@ class Layouts extends Items
return $input;
}
/**
* Converts layouts to blocks
* @since 3.6.0
*
* @param bool $includeHidden Sets whether to include hidden blocks
* @return \Kirby\Cms\Blocks
*/
public function toBlocks(bool $includeHidden = false)
{
$blocks = [];
if ($this->isNotEmpty() === true) {
foreach ($this->data() as $layout) {
foreach ($layout->columns() as $column) {
foreach ($column->blocks($includeHidden) as $block) {
$blocks[] = $block->toArray();
}
}
}
}
return Blocks::factory($blocks);
}
}