Add title attribute to custom block to facilitate easier testing

This commit is contained in:
Matt Sherman 2023-08-24 21:32:35 -04:00
parent ed0d45178f
commit 44575d6dca
2 changed files with 10 additions and 3 deletions

View File

@ -18,11 +18,16 @@ class CustomBlock extends AbstractBlock implements CustomBlockInterface {
/**
* Custom method.
*
* @param string $title The title.
*/
public function add_custom_inner_block(): BlockInterface {
public function add_custom_inner_block( string $title ): BlockInterface {
$block = new Block(
[
'blockName' => 'custom-inner-block',
'blockName' => 'custom-inner-block',
'attributes' => [
'title' => $title,
],
],
$this->get_root_template(),
$this

View File

@ -8,6 +8,8 @@ use Automattic\WooCommerce\Admin\BlockTemplates\BlockInterface;
interface CustomBlockInterface extends BlockContainerInterface {
/**
* Adds a method to insert a specific custom inner block.
*
* @param string $title The title.
*/
public function add_custom_inner_block(): BlockInterface;
public function add_custom_inner_block( string $title ): BlockInterface;
}