<?php

declare(strict_types=1);

namespace Apexl\Io\Product;

use Apexl\Io\Module;
use Apexl\Io\System\Interfaces\ProvidesRoutesInterface;

/**
 * Product / rate-card catalogue.
 *
 * A saleable and/or purchasable product with price, cost, markup, optional
 * variants (`parent_id`) and active/sold/purchased flags. Generic and
 * host-agnostic: consumers extend it (e.g. a finance module maps a product
 * to nominal accounts + tax codes; a billing module adds plans) without
 * forking the entity. Schema owned: `products` (migration in src/db/migrations).
 *
 * `initialise()` is deleted rather than ported. It registered Product with
 * io-basic-module's entity-route generator, which pointed the generated CRUD
 * routes at `Controller::get`/`put`/`post`/`delete` — methods that do not exist
 * on that abstract base, so all four answered a 500 from callable resolution
 * before the permission they declared was ever read, and they sat at an
 * unprefixed `/entities/…`. The real API is `routes/data/products.php`. io 6
 * drops the generator, io-basic-module and the module store with it.
 */
readonly class ProductModule extends Module implements ProvidesRoutesInterface
{
    public function routes(): void
    {
        foreach (glob(__DIR__ . '/routes/data/*.php') as $file) {
            require $file;
        }
    }
}
