1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-03-22 19:44:04 +00:00

globalUrl: useAssetOrigin() instead of setAssetRoot()

This change was prompted by a phpstan failure after a recent update.
While making this change, I noticed we don't need the macro anymore
as useAssetOrigin() was added to the UrlGenerator earlier this year,
simplifying our implementation.
This commit is contained in:
Samuel Štancl 2025-11-14 10:58:35 +01:00
parent 0cd0bc44b1
commit 45cf7029af
No known key found for this signature in database
GPG key ID: BA146259A1E16C57
3 changed files with 9 additions and 19 deletions

View file

@ -6,6 +6,7 @@ namespace Stancl\Tenancy;
use Closure;
use Illuminate\Cache\CacheManager;
use Illuminate\Contracts\Container\Container;
use Illuminate\Database\Console\Migrations\FreshCommand;
use Illuminate\Routing\Events\RouteMatched;
use Illuminate\Support\Facades\Event;
@ -157,12 +158,13 @@ class TenancyServiceProvider extends ServiceProvider
$this->loadRoutesFrom(__DIR__ . '/../assets/routes.php');
}
$this->app->singleton('globalUrl', function ($app) {
$this->app->singleton('globalUrl', function (Container $app) {
if ($app->bound(FilesystemTenancyBootstrapper::class)) {
$instance = clone $app['url'];
$instance->setAssetRoot($app[FilesystemTenancyBootstrapper::class]->originalAssetUrl);
/** @var \Illuminate\Routing\UrlGenerator */
$instance = clone $app->make('url');
$instance->useAssetOrigin($app->make(FilesystemTenancyBootstrapper::class)->originalAssetUrl);
} else {
$instance = $app['url'];
$instance = $app->make('url');
}
return $instance;