<?php
namespace EasyRestaurantManager\Modules\Blocks;
use EasyRestaurantManager\Http\View;

class CategoryBlocks {
    private $blockName = 'easy-restaurant-manager/category-block';

    public function init()
    {
        register_block_type($this->blockName, array(
            'editor_script' => 'easy-restaurant-manager/category-block',
            'render_callback' => [$this, 'render_menu_block']
        ));
    }

    public function render_menu_block($attributes)
    {
        return View::make('Blocks/CategoryBlock', [
            'attributes' => $attributes,
            'categories' => BlockManager::getCategories(),
            'add_category_url' => admin_url('admin.php?page=easy-restaurant-manager.php#/category')
        ]);
    }
}