helick /
blocks
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Helick\Blocks\Traits; |
||
| 4 | |||
| 5 | use Carbon_Fields\Block as CarbonFieldsBlock; |
||
| 6 | use Helick\Blocks\Exceptions\BlockException; |
||
| 7 | |||
| 8 | trait Composable |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * Compose the block. |
||
| 12 | * |
||
| 13 | * @return void |
||
| 14 | */ |
||
| 15 | public function compose(): void |
||
| 16 | { |
||
| 17 | if (empty($this->name)) { |
||
| 18 | throw BlockException::forEmptyName(); |
||
| 19 | } |
||
| 20 | |||
| 21 | CarbonFieldsBlock::make($this->name) |
||
| 22 | ->add_fields($this->fields()) |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 23 | ->set_description($this->description) |
||
| 24 | ->set_icon($this->icon) |
||
| 25 | ->set_category($this->category) |
||
| 26 | ->set_keywords($this->keywords) |
||
| 27 | ->set_preview_mode($this->preview) |
||
| 28 | ->set_parent($this->parent) |
||
| 29 | ->set_inner_blocks($this->nested) |
||
| 30 | ->set_inner_blocks_position($this->nestedPosition) |
||
| 31 | ->set_inner_blocks_template($this->nestedTemplates) |
||
| 32 | ->set_inner_blocks_template_lock($this->nestedLock) |
||
| 33 | ->set_allowed_inner_blocks($this->nestedBlocks) |
||
| 34 | ->set_render_callback([$this, 'render']); |
||
| 35 | } |
||
| 36 | } |
||
| 37 |