<?php

declare(strict_types=1);

namespace Apexl\Io\BasicModule\BasicApi;

use Apexl\Config\ConfigurationInterface;
use Apexl\Io\BasicModule\BasicApi\Services\BasicModuleEntityStore;
use Apexl\Io\Module;
use Apexl\Io\User\Interfaces\ProvidesPermissionsInterface;
use Apexl\Io\User\Services\Permissions;
use Slim\App;

/**
 * A base for modules that keep a list of entities and want the user module's conventions.
 *
 * It used to declare CRUD routes for every registered entity against `Controller::<verb>` —
 * a class that is abstract and has no get, put, post or delete. The route builder recognised
 * those as placeholders and skipped every one, so this registered nothing at all, in every
 * consuming app, for as long as it has existed. Removed rather than reimplemented: there are
 * no controllers behind it to point at.
 */
readonly class BasicApiModule extends Module implements ProvidesPermissionsInterface
{
    public function __construct(
        protected BasicModuleEntityStore $moduleStore,
        ConfigurationInterface $config,
        App $app,
    ) {
        parent::__construct($config, $app);
    }

    protected function moduleStoreKey(): string
    {
        return $this::class;
    }

    public function permissions(Permissions $permissions): void
    {
        //Implement this in your main module file.
        //e.g. $permissions->registerPermission(Module::Permission, 'Module Permission', 'Module Permission Group');
    }
}
