mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-09-01 21:00:58 +00:00
refactor: adopt modular domain architecture (#747)
* refactor: stabilize model identities for domain migration * refactor: extract module platform context * refactor: assign models to domain contexts * refactor: extract ai platform context * refactor: extract storage platform context * refactor: extract mail platform context * refactor: extract pdf platform context * refactor: extract operations platform context * refactor: move installation into operations platform * refactor: extract money domain context * refactor: extract taxation domain context * refactor: extract catalog domain context * refactor: extract metadata domain context * refactor: extract reporting domain context * refactor: extract purchases domain context * refactor: extract receivables domain context * refactor: extract accounts domain context * refactor: complete reporting statement boundary * refactor: extract contacts domain context * refactor: extract sales domain context * refactor: remove legacy application layers * fix: migrate legacy bouncer role identities
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Platform\Modules\Http\Controllers\Assets;
|
||||
|
||||
use App\Platform\Http\Controller;
|
||||
use App\Platform\Modules\Runtime\ModuleAssetVersion;
|
||||
use DateTime;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use InvoiceShelf\Modules\Registry as ModuleRegistry;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
class ScriptController extends Controller
|
||||
{
|
||||
/**
|
||||
* Serve the requested module-registered script.
|
||||
*
|
||||
* Modules call \InvoiceShelf\Modules\Registry::registerScript($name, $path)
|
||||
* from their ServiceProvider::boot() to inject custom JS into the host app.
|
||||
*
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public function __invoke(Request $request, string $script): Response
|
||||
{
|
||||
$path = ModuleRegistry::scriptFor($script);
|
||||
|
||||
abort_if($path === null || ! is_file($path), 404);
|
||||
|
||||
$contents = file_get_contents($path);
|
||||
abort_if(! is_string($contents), 404);
|
||||
$version = ModuleAssetVersion::forContents($contents);
|
||||
$cacheControl = is_string($request->query('v')) && hash_equals($version, $request->query('v'))
|
||||
? 'public, max-age=31536000, immutable'
|
||||
: 'no-store';
|
||||
|
||||
$response = response(
|
||||
$contents,
|
||||
200,
|
||||
[
|
||||
'Content-Type' => 'application/javascript',
|
||||
]
|
||||
)->setLastModified(DateTime::createFromFormat('U', (string) filemtime($path)));
|
||||
|
||||
$response->headers->set('Cache-Control', $cacheControl);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Platform\Modules\Http\Controllers\Assets;
|
||||
|
||||
use App\Platform\Http\Controller;
|
||||
use App\Platform\Modules\Runtime\ModuleAssetVersion;
|
||||
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 || ! is_file($path), 404);
|
||||
|
||||
$contents = file_get_contents($path);
|
||||
abort_if(! is_string($contents), 404);
|
||||
$version = ModuleAssetVersion::forContents($contents);
|
||||
$cacheControl = is_string($request->query('v')) && hash_equals($version, $request->query('v'))
|
||||
? 'public, max-age=31536000, immutable'
|
||||
: 'no-store';
|
||||
|
||||
$response = response(
|
||||
$contents,
|
||||
200,
|
||||
[
|
||||
'Content-Type' => 'text/css',
|
||||
]
|
||||
)->setLastModified(DateTime::createFromFormat('U', (string) filemtime($path)));
|
||||
|
||||
$response->headers->set('Cache-Control', $cacheControl);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user