Skip to content

Commit

Permalink
♻ Simplify the localized block stub
Browse files Browse the repository at this point in the history
  • Loading branch information
Log1x committed Aug 13, 2024
1 parent c9402d4 commit bcc91d8
Show file tree
Hide file tree
Showing 2 changed files with 184 additions and 108 deletions.
108 changes: 0 additions & 108 deletions src/Console/stubs/block.construct.stub

This file was deleted.

184 changes: 184 additions & 0 deletions src/Console/stubs/block.localized.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
<?php

namespace DummyNamespace;

use Log1x\AcfComposer\Block;
use Log1x\AcfComposer\Builder;

class DummyClass extends Block
{
/**
* The block slug.
*
* @var string
*/
public $slug = 'DummySnake';

/**
* The block category.
*
* @var string
*/
public $category = 'DummyCategory';

/**
* The block icon.
*
* @var string|array
*/
public $icon = 'editor-ul';

/**
* The block keywords.
*
* @var array
*/
public $keywords = [];

/**
* The block post type allow list.
*
* @var array
*/
public $post_types = [DummyPostTypes];

/**
* The parent block type allow list.
*
* @var array
*/
public $parent = [];

/**
* The ancestor block type allow list.
*
* @var array
*/
public $ancestor = [];

/**
* The default block mode.
*
* @var string
*/
public $mode = 'preview';

/**
* The default block alignment.
*
* @var string
*/
public $align = '';

/**
* The default block text alignment.
*
* @var string
*/
public $align_text = '';

/**
* The default block content alignment.
*
* @var string
*/
public $align_content = '';

/**
* The supported block features.
*
* @var array
*/
public $supports = [
DummySupports
];

/**
* The block styles.
*
* @var array
*/
public $styles = ['light', 'dark'];

/**
* The block preview example data.
*
* @var array
*/
public $example = [
'items' => [
['item' => 'Item one'],
['item' => 'Item two'],
['item' => 'Item three'],
],
];

/**
* The block template.
*
* @var array
*/
public $template = [
'core/heading' => ['placeholder' => 'Hello World'],
'core/paragraph' => ['placeholder' => 'Welcome to the DummyTitle block.'],
];

/**
* The block name.
*/
public function getName(): string
{
return __('DummyTitle', 'sage');
}

/**
* The block description.
*/
public function getDescription(): string
{
return __('DummyDescription', 'sage');
}

/**
* Data to be passed to the block before rendering.
*/
public function with(): array
{
return [
'items' => $this->items(),
];
}

/**
* The block field group.
*/
public function fields(): array
{
$fields = Builder::make('DummySnake');

$fields
->addRepeater('items')
->addText('item')
->endRepeater();

return $fields->build();
}

/**
* Retrieve the items.
*
* @return array
*/
public function items()
{
return get_field('items') ?: $this->example['items'];
}

/**
* Assets enqueued when rendering the block.
*/
public function assets(array $block): void
{
//
}
}

0 comments on commit bcc91d8

Please sign in to comment.