1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 19:14:04 +00:00

Rewrite cached resolver logic to allow for cache invalidation logic

This commit is contained in:
Samuel Štancl 2020-06-02 20:10:17 +02:00
parent b176481cdf
commit 5d94727ddd
15 changed files with 189 additions and 117 deletions

View file

@ -6,14 +6,22 @@ namespace Stancl\Tenancy\Resolvers;
use Illuminate\Routing\Route;
use Stancl\Tenancy\Contracts\Tenant;
use Stancl\Tenancy\Contracts\TenantResolver;
use Stancl\Tenancy\Exceptions\TenantCouldNotBeIdentifiedByPathException;
class PathTenantResolver implements TenantResolver
class PathTenantResolver extends Contracts\CachedTenantResolver
{
public static $tenantParameterName = 'tenant';
public function resolve(...$args): Tenant
/** @var bool */
public static $shouldCache = false;
/** @var int */
public static $cacheTTL = 3600; // seconds
/** @var string|null */
public static $cacheStore = null; // default
public function resolveWithoutCache(...$args): Tenant
{
/** @var Route $route */
$route = $args[0];
@ -28,4 +36,11 @@ class PathTenantResolver implements TenantResolver
throw new TenantCouldNotBeIdentifiedByPathException($id);
}
public function getArgsForTenant(Tenant $tenant): array
{
return [
[$tenant->id],
];
}
}