Skip to content

Commit 5ac11a9

Browse files
authored
Merge pull request #3 from AlexP11223/feature/gutenberg
2 parents ed8d800 + eb122fc commit 5ac11a9

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

77
## [[*next-version*]] - YYYY-MM-DD
8+
### Added
9+
- Interfaces for Gutenberg blocks parsing.
810

911
## [0.1.0-alpha1] - 2021-03-05
1012
Initial version.

src/Gutenberg/BlockInterface.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace WpOop\WordPress\Gutenberg;
6+
7+
/**
8+
* The interface for Gutenberg block data.
9+
*/
10+
interface BlockInterface
11+
{
12+
/**
13+
* Returns name of the block, such as 'core/paragraph'.
14+
*/
15+
public function getBlockName(): string;
16+
17+
/**
18+
* Returns block attributes.
19+
* @return array<string, mixed>
20+
*/
21+
public function getAttributes(): array;
22+
23+
/**
24+
* Returns inner blocks (for example, used in the Columns block).
25+
* @return BlockInterface[]
26+
*/
27+
public function getInnerBlocks(): array;
28+
29+
/**
30+
* Returns resultant HTML.
31+
*/
32+
public function getInnerHtml(): string;
33+
34+
/**
35+
* Returns list of string fragments and null markers where inner blocks were found.
36+
* @return array<?string>
37+
*/
38+
public function getInnerContent(): array;
39+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace WpOop\WordPress\Gutenberg;
6+
7+
/**
8+
* The interface for parsing Gutenberg blocks.
9+
*/
10+
interface BlockParserInterface
11+
{
12+
/**
13+
* @param string $postContent Content of a WP post (e.g. WP_Post post_content).
14+
* @return BlockInterface[]
15+
*/
16+
public function parseBlock(string $postContent): array;
17+
}

0 commit comments

Comments
 (0)