<?php

// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedNamespaceFound -- APD is the established namespace shared with the Pro add-on and retained for backward compatibility.
namespace APD\Gutenberg;

use APD\Admin\AdminSettings;
use APD\Container;
use APD\Contracts\ServiceProviderInterface;

defined('ABSPATH') || exit;

class GutenbergServiceProvider implements ServiceProviderInterface
{
    public function __construct(protected Container $container)
    {
    }

    public function register() : void
    {
    }

    public function boot() : void
    {
        $settings = $this->container->get(AdminSettings::class)->all();
        if (($settings['enable_gutenberg'] ?? '1') !== '1') {
            return;
        }

        add_action('init', [new BlockRegistration($this->container->get(AdminSettings::class)), 'register']);
    }
}
