74 lines
2.4 KiB
PHP
74 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace IriksIT\Manager\Contracts;
|
|
|
|
use IriksIT\Manager\Support\Permission;
|
|
|
|
/**
|
|
* One switchable part of the manager. A module that is off contributes nothing:
|
|
* no routes, no migrations, no menu items, no permissions.
|
|
*/
|
|
interface Module
|
|
{
|
|
/** Short unique key, also the key in config('manager.modules'). */
|
|
public function key(): string;
|
|
|
|
/** Name in the menu. */
|
|
public function label(): string;
|
|
|
|
/** Core modules (users, media) are on unless a site explicitly turns them off. */
|
|
public function enabledByDefault(): bool;
|
|
|
|
/** @return list<string> keys of modules this one cannot work without */
|
|
public function requires(): array;
|
|
|
|
/**
|
|
* Permissions this module adds. Values are prefixed by the module key.
|
|
*
|
|
* @return list<Permission>
|
|
*/
|
|
public function permissions(): array;
|
|
|
|
/** @return list<array{label: string, route: string, permission: string}> */
|
|
public function navigation(): array;
|
|
|
|
/** Absolute path of the routes file, or null. */
|
|
public function routes(): ?string;
|
|
|
|
/** Absolute path of a routes file outside the manager (no prefix, no manager middleware), or null. */
|
|
public function publicRoutes(): ?string;
|
|
|
|
/** Absolute path of the migrations folder, or null. */
|
|
public function migrations(): ?string;
|
|
|
|
/** @return list<class-string> Artisan commands this module adds */
|
|
public function commands(): array;
|
|
|
|
/**
|
|
* What the audit log calls each thing that is done through this module's routes, by route
|
|
* name without the `manager.` prefix: `[label]` or `[label, [form fields that may be kept]]`.
|
|
* Never list a field a secret could be typed in.
|
|
*
|
|
* @return array<string, array{0: string, 1?: list<string>}>
|
|
*/
|
|
public function actions(): array;
|
|
|
|
/**
|
|
* What the audit log calls opening a page (a GET route), by route name without `manager.`.
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
public function views(): array;
|
|
|
|
/**
|
|
* Middleware this module wants around every manager route: `before` runs ahead of the site's
|
|
* own manager middleware (session, login), `after` behind it.
|
|
*
|
|
* @return array{before?: list<string>, after?: list<string>}
|
|
*/
|
|
public function middleware(): array;
|
|
|
|
/** Runs at boot, only when the module is on (register rate limiters, usage sources, ...). */
|
|
public function boot(): void;
|
|
}
|