<?php

declare(strict_types=1);

namespace apexl\Io\modules\product;

use apexl\Io\includes\RouteManager;
use apexl\Io\modules\BasicApi\BasicApiModule;
use apexl\Io\modules\product\Entity\Product;
use apexl\Io\modules\system\interfaces\ProvidesRoutesInterface;

/**
 * Product / rate-card catalogue (V3).
 *
 * 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).
 */
class productModule extends BasicApiModule implements ProvidesRoutesInterface
{
    public function initialise(): void
    {
        $this->moduleStore->add($this->moduleStoreKey(), [
            new Product(),
        ]);
    }

    public function routes(RouteManager $routeManager): void
    {
        parent::routes($routeManager);
        foreach (glob(__DIR__ . '/routes/data/*.php') as $file) {
            require $file;
        }
    }
}
