<?php
/**
 * BookiFlex Core
 *
 * @package    BookiFlex
 * @subpackage Core
 * @author     BookiFlex
 * @copyright  Copyright (c) 2025 BookiFlex
 * @license    GPL-2.0-or-later
 *
 * @link       https://bookiflex.com
 */


declare(strict_types=1);
namespace BookiFlex\Core\Admin\Block;

use BookiFlex\Core\Contract\PluginInterface;

defined( 'ABSPATH' ) || exit;

abstract class AbstractBlock
{
    public function __construct(
        protected PluginInterface $plugin
    ) {}

    /**
     * Absolute path to the directory containing block.json.
     * WordPress reads all block metadata from that file automatically.
     */
    abstract protected function blockDir(): string;

    abstract public function render(array $attributes, string $content, ?\WP_Block $block = null): string;

    public function register(): void
    {
        register_block_type($this->blockDir(), [
            'render_callback' => [$this, 'render'],
        ]);
    }
}
