87 lines
1.6 KiB
PHP
87 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace IriksIT\Manager\Modules;
|
|
|
|
use IriksIT\Manager\Contracts\Module;
|
|
|
|
/**
|
|
* Convention over configuration: a module `Foo` lives in src/Modules/Foo, with
|
|
* routes.php and a migrations/ folder next to its class when it needs them.
|
|
*/
|
|
abstract class BaseModule implements Module
|
|
{
|
|
public function enabledByDefault(): bool
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public function requires(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
public function permissions(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
public function navigation(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
public function routes(): ?string
|
|
{
|
|
return $this->path('routes.php');
|
|
}
|
|
|
|
public function publicRoutes(): ?string
|
|
{
|
|
return $this->path('public-routes.php');
|
|
}
|
|
|
|
public function commands(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
/**
|
|
* Tables (without the prefix) this module needs; `manager:doctor` checks that they exist.
|
|
*
|
|
* @return list<string>
|
|
*/
|
|
public function tables(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
public function actions(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
public function views(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
public function middleware(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
public function boot(): void {}
|
|
|
|
public function migrations(): ?string
|
|
{
|
|
return $this->path('migrations');
|
|
}
|
|
|
|
private function path(string $name): ?string
|
|
{
|
|
$path = dirname((new \ReflectionClass($this))->getFileName()).'/'.$name;
|
|
|
|
return file_exists($path) ? $path : null;
|
|
}
|
|
}
|