<?php

namespace Apexl\Io\Menu;

use Apexl\Io\Interfaces\ProvidesHooksInterface;
use Apexl\Io\Menu\Hooks\RegisterMenuItems;
use Apexl\Io\Module;
use Apexl\Io\System\Interfaces\ProvidesRoutesInterface;

readonly class MenuModule extends Module implements ProvidesHooksInterface, ProvidesRoutesInterface
{

    public function hooks(): array
    {
        return [
            RegisterMenuItems::class,
        ];
    }

    /**
     * Phase 5 (quiet mode) — adds the nav-groups catalogue endpoint
     * (`/api/v1/menu/nav-groups`). io-menu had no HTTP surface before
     * this; kept to a single glob so any future route file just needs to
     * be dropped in routes/data/.
     *
     * A required file runs in this method's scope, so those files register with the module's
     * own `$this->get()` and the rest; Slim itself is private and out of their reach.
     */
    public function routes(): void
    {
        foreach (glob(__DIR__ . '/routes/data/*.php') as $file) {
            require $file;
        }
    }
}
