API / Minn\Blocks / Block

Block final readonly class

Minn\Blocks\Block · public/minn/src/Minn/Blocks/Block.php · 63 lines

One parsed block. A null name is freeform HTML between blocks. The innerContent list holds the block's own HTML chunks in order, with a null placeholder wherever an inner block sits.

Constants and properties

propreadonly ?string $name

Promoted from the constructor.

propreadonly array $attrs

Promoted from the constructor.

propreadonly array $innerBlocks

Promoted from the constructor.

propreadonly string $innerHtml

Promoted from the constructor.

propreadonly array $innerContent

Promoted from the constructor.

Public

new__construct(?string $name, array $attrs, array $innerBlocks, string $innerHtml, array $innerContent)#
staticfreeform(string $html): self#

A block-less run of HTML, as the parser reads it.

staticfromArray(array $block): self#

A block as parse_blocks hands it out, as the value object. @param array<string, mixed> $block

$blockarray<string, mixed>
methodwithAttrs(array $attrs): self#

The same block with other attributes. @param array<string, mixed> $attrs

$attrsarray<string, mixed>
methodtoArray(): array#

The block as parse_blocks hands it to plugin code.

@return array{blockName: ?string, attrs: array<string, mixed>, innerBlocks: list<array<string, mixed>>, innerHTML: string, innerContent: list<string|null>}
methodattr(string $key, mixed $default = NULL): mixed#

One attribute, or the default.

methodclassName(): string#

The class names declared on the block's own attributes (className).