Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace Automattic\BlocksEngine\PhpTransformer\HtmlToBlocks\Elements;

use Automattic\BlocksEngine\PhpTransformer\HtmlToBlocks\Classification\SourceElementClassifier;
use Automattic\BlocksEngine\PhpTransformer\HtmlToBlocks\Patterns\PatternContext;
use Closure;
use DOMElement;
Expand All @@ -17,8 +18,7 @@ public function __construct(
private readonly Closure $recognizePatterns,
private readonly Closure $flankedSeparatorBlock,
private readonly Closure $capturedMediaLayoutBlock,
private readonly Closure $hasResponsiveImageSources,
private readonly Closure $hasGalleryMediaItems,
private readonly SourceElementClassifier $sourceElementClassifier,
private readonly Closure $responsiveMediaBlock,
private readonly Closure $isDirectChildOfAuthorOwnedLayout,
private readonly Closure $authorLayoutBlock,
Expand All @@ -45,7 +45,6 @@ public function __construct(
private readonly Closure $generatedComponentBlock,
private readonly Closure $textFlowBlock,
private readonly Closure $convertChildren,
private readonly Closure $hasDirectMediaChild,
private readonly Closure $backgroundImageBlock,
private readonly Closure $coalescedSingleGroupWrapper,
private readonly Closure $shouldPreserveWrapper,
Expand All @@ -65,8 +64,8 @@ public function recognizePatterns(DOMElement $element, array &$fallbacks, array
public function flankedSeparatorBlock(DOMElement $element): ?array { return ($this->flankedSeparatorBlock)($element); }
/** @return array<string, mixed>|null */
public function capturedMediaLayoutBlock(DOMElement $element): ?array { return ($this->capturedMediaLayoutBlock)($element); }
public function hasResponsiveImageSources(DOMElement $element): bool { return ($this->hasResponsiveImageSources)($element); }
public function hasGalleryMediaItems(DOMElement $element): bool { return ($this->hasGalleryMediaItems)($element); }
public function hasResponsiveImageSources(DOMElement $element): bool { return $this->sourceElementClassifier->hasResponsiveImageSources($element); }
public function hasGalleryMediaItems(DOMElement $element): bool { return $this->sourceElementClassifier->hasGalleryMediaItems($element); }
/** @return array<string, mixed> */
public function responsiveMediaBlock(DOMElement $element): array { return ($this->responsiveMediaBlock)($element); }
public function isDirectChildOfAuthorOwnedLayout(DOMElement $element): bool { return ($this->isDirectChildOfAuthorOwnedLayout)($element); }
Expand Down Expand Up @@ -111,7 +110,7 @@ public function generatedComponentBlock(DOMElement $element): ?array { return ($
public function textFlowBlock(DOMElement $element): ?array { return ($this->textFlowBlock)($element); }
/** @param array<int, array<string, mixed>> $fallbacks @return array<int, array<string, mixed>> */
public function convertChildren(DOMElement $element, array &$fallbacks): array { return ($this->convertChildren)($element, $fallbacks); }
public function hasDirectMediaChild(DOMElement $element): bool { return ($this->hasDirectMediaChild)($element); }
public function hasDirectMediaChild(DOMElement $element): bool { return $this->sourceElementClassifier->hasDirectMediaChild($element); }
/** @return array<string, mixed>|null */
public function backgroundImageBlock(DOMElement $element): ?array { return ($this->backgroundImageBlock)($element); }
/** @param array<string, mixed> $child @return array<string, mixed>|null */
Expand Down
4 changes: 1 addition & 3 deletions php-transformer/src/HtmlToBlocks/HtmlTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -788,8 +788,7 @@ function (DOMElement $element, array &$fallbacks, bool $captureUnsupported): arr
recognizePatterns: fn (DOMElement $element, array &$fallbacks, array $patterns): ?array => $this->recognizePatterns($element, $fallbacks, $patterns),
flankedSeparatorBlock: fn (DOMElement $element): ?array => $this->flankedSeparatorBlockFromElement($element),
capturedMediaLayoutBlock: fn (DOMElement $element): ?array => $this->capturedMediaLayoutBoundaryBlock($element),
hasResponsiveImageSources: fn (DOMElement $element): bool => $this->sourceElementClassifier->hasResponsiveImageSources($element),
hasGalleryMediaItems: fn (DOMElement $element): bool => $this->sourceElementClassifier->hasGalleryMediaItems($element),
sourceElementClassifier: $this->sourceElementClassifier,
responsiveMediaBlock: fn (DOMElement $element): array => $this->responsiveMediaBlock($element),
isDirectChildOfAuthorOwnedLayout: fn (DOMElement $element): bool => $this->isDirectChildOfAuthorOwnedLayout($element),
authorLayoutBlock: fn (DOMElement $element, array &$fallbacks): array => $this->authorLayoutBlockFromElement($element, $fallbacks),
Expand Down Expand Up @@ -819,7 +818,6 @@ function (DOMElement $element, array &$fallbacks, bool $captureUnsupported): arr
},
textFlowBlock: fn (DOMElement $element): ?array => $this->textFlowBlockFromElement($element),
convertChildren: fn (DOMElement $element, array &$fallbacks): array => $this->convertChildren($element, $fallbacks, true),
hasDirectMediaChild: fn (DOMElement $element): bool => $this->sourceElementClassifier->hasDirectMediaChild($element),
backgroundImageBlock: fn (DOMElement $element): ?array => $this->backgroundImageBlockFromElement($element),
coalescedSingleGroupWrapper: fn (DOMElement $element, array $child): ?array => $this->coalescedSingleGroupWrapper($element, $child),
shouldPreserveWrapper: fn (DOMElement $element): bool => $this->shouldPreserveWrapper($element),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

require __DIR__ . '/../../vendor/autoload.php';

use Automattic\BlocksEngine\PhpTransformer\HtmlToBlocks\Classification\SourceElementClassifier;
use Automattic\BlocksEngine\PhpTransformer\HtmlToBlocks\Elements\FlowContainerElementContext;
use Automattic\BlocksEngine\PhpTransformer\HtmlToBlocks\Elements\FlowContainerElementConverter;
use Automattic\BlocksEngine\PhpTransformer\HtmlToBlocks\Patterns\PatternContext;
Expand Down Expand Up @@ -39,8 +40,7 @@
},
'flankedSeparatorBlock' => $null,
'capturedMediaLayoutBlock' => $null,
'hasResponsiveImageSources' => $false,
'hasGalleryMediaItems' => $false,
'sourceElementClassifier' => new SourceElementClassifier(),
'responsiveMediaBlock' => static fn (): array => array( 'blockName' => 'responsive-media' ),
'isDirectChildOfAuthorOwnedLayout' => $false,
'authorLayoutBlock' => static fn (): array => array( 'blockName' => 'author-layout' ),
Expand Down Expand Up @@ -80,7 +80,6 @@
}
return array();
},
'hasDirectMediaChild' => $false,
'backgroundImageBlock' => $null,
'coalescedSingleGroupWrapper' => $null,
'shouldPreserveWrapper' => $false,
Expand Down
Loading