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

Merge branch 'archtechx:3.x' into 3.x

This commit is contained in:
Leandro Gehlen 2024-05-15 09:12:38 -03:00 committed by GitHub
commit 394d6ad338
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 88 additions and 26 deletions

View file

@ -28,8 +28,8 @@ class RedisTenancyBootstrapper implements TenancyBootstrapper
$prefix = $this->config['tenancy.redis.prefix_base'] . $tenant->getTenantKey();
$client = Redis::connection($connection)->client();
$this->originalPrefixes[$connection] = $client->getOption($client::OPT_PREFIX);
$client->setOption($client::OPT_PREFIX, $prefix);
$this->originalPrefixes[$connection] = $client->getOption(\Redis::OPT_PREFIX);
$client->setOption(\Redis::OPT_PREFIX, $prefix);
}
}
@ -38,7 +38,7 @@ class RedisTenancyBootstrapper implements TenancyBootstrapper
foreach ($this->prefixedConnections() as $connection) {
$client = Redis::connection($connection)->client();
$client->setOption($client::OPT_PREFIX, $this->originalPrefixes[$connection]);
$client->setOption(\Redis::OPT_PREFIX, $this->originalPrefixes[$connection]);
}
$this->originalPrefixes = [];

View file

@ -25,6 +25,7 @@ final class MigrateFresh extends Command
parent::__construct();
$this->addOption('--drop-views', null, InputOption::VALUE_NONE, 'Drop views along with tenant tables.', null);
$this->addOption('--step', null, InputOption::VALUE_NONE, 'Force the migrations to be run so they can be rolled back individually.');
$this->setName('tenants:migrate-fresh');
}
@ -47,6 +48,7 @@ final class MigrateFresh extends Command
$this->info('Migrating.');
$this->callSilent('tenants:migrate', [
'--tenants' => [$tenant->getTenantKey()],
'--step' => $this->option('step'),
'--force' => true,
]);
});

View file

@ -10,8 +10,7 @@ use Symfony\Component\Console\Output\OutputInterface;
trait TenantAwareCommand
{
/** @return int */
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$tenants = $this->getTenants();
$exitCode = 0;

View file

@ -35,7 +35,7 @@ class UniversalRoutes implements Feature
public static function routeHasMiddleware(Route $route, $middleware): bool
{
if (in_array($middleware, $route->middleware(), true)) {
if (in_array($middleware, $route->computedMiddleware ?? $route->middleware(), true)) {
return true;
}

View file

@ -37,6 +37,14 @@ class PathTenantResolver extends Contracts\CachedTenantResolver
throw new TenantCouldNotBeIdentifiedByPathException($id);
}
public function resolved(Tenant $tenant, ...$args): void
{
/** @var Route $route */
$route = $args[0];
$route->forgetParameter(static::$tenantParameterName);
}
public function getArgsForTenant(Tenant $tenant): array
{
return [

View file

@ -15,6 +15,6 @@ class Vite extends BaseVite // todo move to a different directory in v4
*/
protected function assetPath($path, $secure = null)
{
return global_asset($path);
return $this->assetPathResolver ? ($this->assetPathResolver)($path, $secure) : global_asset($path);
}
}