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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [[*next-version*]] - YYYY-MM-DD
### Added
- Interfaces for Gutenberg blocks parsing.

## [0.1.0-alpha1] - 2021-03-05
Initial version.
39 changes: 39 additions & 0 deletions src/Gutenberg/BlockInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

namespace WpOop\WordPress\Gutenberg;

/**
* The interface for Gutenberg block data.
*/
interface BlockInterface
{
/**
* Returns name of the block, such as 'core/paragraph'.
*/
public function getBlockName(): string;

/**
* Returns block attributes.
* @return array<string, mixed>
*/
public function getAttributes(): array;

/**
* Returns inner blocks (for example, used in the Columns block).
* @return BlockInterface[]
*/
public function getInnerBlocks(): array;

/**
* Returns resultant HTML.
*/
public function getInnerHtml(): string;

/**
* Returns list of string fragments and null markers where inner blocks were found.
* @return array<?string>
*/
public function getInnerContent(): array;
}
17 changes: 17 additions & 0 deletions src/Gutenberg/BlockParserInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace WpOop\WordPress\Gutenberg;

/**
* The interface for parsing Gutenberg blocks.
*/
interface BlockParserInterface
{
/**
* @param string $postContent Content of a WP post (e.g. WP_Post post_content).
* @return BlockInterface[]
*/
public function parseBlock(string $postContent): array;
}