mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-15 17:24:10 +00:00
The vestigial App\Services\Module\Module static class — with its unused
\$scripts / \$styles / \$settings registries — never had any of its helpers
wired up. The new InvoiceShelf\Modules\Registry shipped from the
invoiceshelf/modules package supersedes it cleanly: same static-array surface
(\$menu, \$settings, \$scripts, \$styles), but lives outside the host app so
third-party modules can depend on it without importing v3-app internals.
Three consumers in the host app are migrated to the new namespace:
- ScriptController and StyleController (the HTTP endpoints that serve
module-registered JS/CSS assets at /modules/scripts/{name} and
/modules/styles/{name}) now look up paths via Registry::scriptFor() and
Registry::styleFor() instead of Arr::get(ModuleFacade::all*(), \$name).
Also tightens type hints — Request import + Response return type.
- resources/views/app.blade.php iterates Registry::allStyles() /
Registry::allScripts() to inject module-supplied <link>/<script> tags into
the main layout. Same Akaunting-style asset injection mechanism, just
reading from the new namespace.
Both Module and ModuleFacade are deleted — they had no remaining callers
after this migration.
37 lines
1.0 KiB
PHP
37 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Modules;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use DateTime;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Response;
|
|
use InvoiceShelf\Modules\Registry as ModuleRegistry;
|
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|
|
|
class StyleController extends Controller
|
|
{
|
|
/**
|
|
* Serve the requested module-registered stylesheet.
|
|
*
|
|
* Modules call \InvoiceShelf\Modules\Registry::registerStyle($name, $path)
|
|
* from their ServiceProvider::boot() to inject custom CSS into the host app.
|
|
*
|
|
* @throws NotFoundHttpException
|
|
*/
|
|
public function __invoke(Request $request, string $style): Response
|
|
{
|
|
$path = ModuleRegistry::styleFor($style);
|
|
|
|
abort_if($path === null, 404);
|
|
|
|
return response(
|
|
file_get_contents($path),
|
|
200,
|
|
[
|
|
'Content-Type' => 'text/css',
|
|
]
|
|
)->setLastModified(DateTime::createFromFormat('U', (string) filemtime($path)));
|
|
}
|
|
}
|