API / Minn\Blocks / Layout

Layout final class

Minn\Blocks\Layout · public/minn/src/Minn/Blocks/Layout.php · 167 lines

The layout support's classes and rules (wp_render_layout_support_flag, probe block-supports), for core and plugin blocks alike:

- is-layout-{type} and {block}-is-layout-{type} for the layout the block uses (its own over its type's default), with has-global-padding for a constrained layout under a theme with root-padding-aware alignments; - is-vertical or is-horizontal, is-content-justification-* and is-nowrap from the layout the block itself stores; - a wp-container-{block}-is-layout-* class when the layout writes CSS (LayoutStyle), and wp-container-content-* for a child's own size or place in its parent's layout.

The rules go to the page's block-support styles through the private minn_block_support_rules action. A container class's suffix is a digest the engine cannot reproduce (its inputs are not observable), so the engine derives its own from the layout: same shape, different value, which the parity suites normalise.

Public

staticclasses(string $blockName, array $attrs): array#

The layout classes a core block's wrapper carries, under its type's supports (data/blocks.json).

@return list<string>
staticforBlock(string $blockName, array $attrs, array $supports): array#

The layout classes a block's wrapper carries, its container's rules recorded, under the theme's layout settings the render state holds (root-padding-aware alignments, block gaps).

$supportsarray<string, mixed>the block type's supports (layout and its default, spacing)
@return list<string>
staticchildClass(array $child, array $parent): ?string#

The class a child's own layout earns (its size or place in the parent's layout), its rules recorded; null when it writes none.

$childarray<string, mixed>the block's style.layout
$parentarray<string, mixed>the parent's layout
staticsanitizeGap(mixed $gap): mixed#

A block gap as the layout reads it: a value with a character that could end a declaration or open a function (\ ( & = } or a comment) is dropped, a side of one too; anything not a string is left as it is.

staticgapCss(mixed $gap): array|string|null#

A gap with its presets as custom properties, a side at a time.

@return string|array<string, string>|null
staticpaddingCss(array $padding): array#

A block's side padding with its presets as custom properties.

@return array<string, string>
staticwidths(array $layout): array#

A layout with its widths checked: the first declaration of each, through the style attribute filter, empty when that drops it.

@return array<string, mixed>

Internals 5

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatesafeGap(string $value): ?string#
privateskipsGap(array $supports): bool#
$supportsarray<string, mixed>
privateused(array $own, array $supports): array#

The layout a block uses: its own over its type's default; the legacy inherit flag means constrained.

$supportsarray<string, mixed>
@return array<string, mixed>
privatetypeClasses(string $type, array $own): array#
@return list<string>
privaterecord(array $rules): void#
$ruleslist<array<string, mixed>>