Upgrade to 4.0.0
This commit is contained in:
@@ -27,16 +27,12 @@ class Blocks extends Items
|
||||
|
||||
/**
|
||||
* All registered blocks methods
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $methods = [];
|
||||
public static array $methods = [];
|
||||
|
||||
/**
|
||||
* Return HTML when the collection is
|
||||
* converted to a string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
@@ -47,11 +43,8 @@ class Blocks extends Items
|
||||
* Converts the blocks to HTML and then
|
||||
* uses the Str::excerpt method to create
|
||||
* a non-formatted, shortened excerpt from it
|
||||
*
|
||||
* @param mixed ...$args
|
||||
* @return string
|
||||
*/
|
||||
public function excerpt(...$args)
|
||||
public function excerpt(mixed ...$args): string
|
||||
{
|
||||
return Str::excerpt($this->toHtml(), ...$args);
|
||||
}
|
||||
@@ -59,13 +52,11 @@ class Blocks extends Items
|
||||
/**
|
||||
* Wrapper around the factory to
|
||||
* catch blocks from layouts
|
||||
*
|
||||
* @param array $items
|
||||
* @param array $params
|
||||
* @return \Kirby\Cms\Blocks
|
||||
*/
|
||||
public static function factory(array $items = null, array $params = [])
|
||||
{
|
||||
public static function factory(
|
||||
array $items = null,
|
||||
array $params = []
|
||||
): static {
|
||||
$items = static::extractFromLayouts($items);
|
||||
|
||||
// @deprecated old editor format
|
||||
@@ -79,9 +70,6 @@ class Blocks extends Items
|
||||
|
||||
/**
|
||||
* Pull out blocks from layouts
|
||||
*
|
||||
* @param array $input
|
||||
* @return array
|
||||
*/
|
||||
protected static function extractFromLayouts(array $input): array
|
||||
{
|
||||
@@ -115,9 +103,6 @@ class Blocks extends Items
|
||||
/**
|
||||
* Checks if a given block type exists in the collection
|
||||
* @since 3.6.0
|
||||
*
|
||||
* @param string $type
|
||||
* @return bool
|
||||
*/
|
||||
public function hasType(string $type): bool
|
||||
{
|
||||
@@ -126,11 +111,8 @@ class Blocks extends Items
|
||||
|
||||
/**
|
||||
* Parse and sanitize various block formats
|
||||
*
|
||||
* @param array|string $input
|
||||
* @return array
|
||||
*/
|
||||
public static function parse($input): array
|
||||
public static function parse(array|string|null $input): array
|
||||
{
|
||||
if (empty($input) === false && is_array($input) === false) {
|
||||
try {
|
||||
@@ -175,16 +157,10 @@ class Blocks extends Items
|
||||
|
||||
/**
|
||||
* Convert all blocks to HTML
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toHtml(): string
|
||||
{
|
||||
$html = [];
|
||||
|
||||
foreach ($this->data as $block) {
|
||||
$html[] = $block->toHtml();
|
||||
}
|
||||
$html = A::map($this->data, fn ($block) => $block->toHtml());
|
||||
|
||||
return implode($html);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user