mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 18:04:03 +00:00
minor improvements for phpstan
This commit is contained in:
parent
62d19c5f5d
commit
f941df3a82
4 changed files with 18 additions and 9 deletions
|
|
@ -15,11 +15,16 @@ class CrossDomainRedirect implements Feature
|
||||||
RedirectResponse::macro('domain', function (string $domain) {
|
RedirectResponse::macro('domain', function (string $domain) {
|
||||||
/** @var RedirectResponse $this */
|
/** @var RedirectResponse $this */
|
||||||
|
|
||||||
// Replace first occurrence of the hostname fragment with $domain
|
|
||||||
$url = $this->getTargetUrl();
|
$url = $this->getTargetUrl();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The original hostname in the redirect response.
|
||||||
|
*
|
||||||
|
* @var string $hostname
|
||||||
|
*/
|
||||||
$hostname = parse_url($url, PHP_URL_HOST);
|
$hostname = parse_url($url, PHP_URL_HOST);
|
||||||
$position = strpos($url, $hostname);
|
|
||||||
$this->setTargetUrl(substr_replace($url, $domain, $position, strlen($hostname)));
|
$this->setTargetUrl((string) str($url)->replace($hostname, $domain));
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ class Tenancy
|
||||||
$tenants = is_string($tenants) ? [$tenants] : $tenants;
|
$tenants = is_string($tenants) ? [$tenants] : $tenants;
|
||||||
|
|
||||||
// Use all tenants if $tenants is falsey
|
// Use all tenants if $tenants is falsey
|
||||||
$tenants = $tenants ?: $this->model()->cursor();
|
$tenants = $tenants ?: $this->model()->cursor(); // todo0 phpstan thinks this isn't needed, but tests fail without it
|
||||||
|
|
||||||
$originalTenant = $this->tenant;
|
$originalTenant = $this->tenant;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,11 +58,15 @@ if (! function_exists('global_cache')) {
|
||||||
if (! function_exists('tenant_route')) {
|
if (! function_exists('tenant_route')) {
|
||||||
function tenant_route(string $domain, string $route, array $parameters = [], bool $absolute = true): string
|
function tenant_route(string $domain, string $route, array $parameters = [], bool $absolute = true): string
|
||||||
{
|
{
|
||||||
// replace the first occurrence of the hostname fragment with $domain
|
|
||||||
$url = route($route, $parameters, $absolute);
|
$url = route($route, $parameters, $absolute);
|
||||||
$hostname = parse_url($url, PHP_URL_HOST);
|
|
||||||
$position = strpos($url, $hostname);
|
|
||||||
|
|
||||||
return substr_replace($url, $domain, $position, strlen($hostname));
|
/**
|
||||||
|
* The original hostname in the generated route.
|
||||||
|
*
|
||||||
|
* @var string $hostname
|
||||||
|
*/
|
||||||
|
$hostname = parse_url($url, PHP_URL_HOST);
|
||||||
|
|
||||||
|
return (string) str($url)->replace($hostname, $domain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
|
||||||
'--realpath' => true,
|
'--realpath' => true,
|
||||||
'--force' => true,
|
'--force' => true,
|
||||||
],
|
],
|
||||||
'tenancy.bootstrappers.redis' => \Stancl\Tenancy\Bootstrappers\RedisTenancyBootstrapper::class,
|
'tenancy.bootstrappers.redis' => \Stancl\Tenancy\Bootstrappers\RedisTenancyBootstrapper::class, // todo0 change this to []? two tests in TenantDatabaseManagerTest are failing with that
|
||||||
'queue.connections.central' => [
|
'queue.connections.central' => [
|
||||||
'driver' => 'sync',
|
'driver' => 'sync',
|
||||||
'central' => true,
|
'central' => true,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue