<?php
declare(strict_types=1);

namespace ProudNerds\Block;

/**
 * Class: Theme
 *
 * Functionality relating to the theme can be added and altered here.
 */
class Theme
{
    /**
     * Block options and settings constructor.
     */
    public function __construct()
    {
        $this->setupBlocks();

    }

    /**
     * Adds the functionality to load blocks
     */
    private function setupBlocks(): void
    {
        $path = get_stylesheet_directory() . '/blocks/';
        $blocks = BlockLoader::loadBlocks($path);
        $acfRenderer = new AcfBlockRenderer();

        // Register blocks
        add_action('acf/init', new AcfBlockRegistrar($acfRenderer, $blocks));

        // Setup rendering
        add_filter('render_block', new BlockRenderer(), 10, 2);
    }


}