mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-13 04:04:04 +00:00
Resolver refactor, path identification improvements (#41)
* resolver refactor * Fix code style (php-cs-fixer) * make tenant column used in PathTenantResolver configurable, fix phpstan errors, minor improvements * support binding route fields, write tests for customizable tenant columns * Invalidate cache for all possible columns in path resolver * implement proper cache separation logic for different columns used by PathTenantResolver * improve return type --------- Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
This commit is contained in:
parent
dc430666ba
commit
0c11f29c19
17 changed files with 370 additions and 88 deletions
18
src/Exceptions/TenantColumnNotWhitelistedException.php
Normal file
18
src/Exceptions/TenantColumnNotWhitelistedException.php
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stancl\Tenancy\Exceptions;
|
||||
|
||||
use Stancl\Tenancy\Contracts\TenantCouldNotBeIdentifiedException;
|
||||
|
||||
class TenantColumnNotWhitelistedException extends TenantCouldNotBeIdentifiedException
|
||||
{
|
||||
public function __construct(int|string $tenant_id)
|
||||
{
|
||||
$this
|
||||
->tenantCouldNotBeIdentified("on path with tenant key: $tenant_id (column not whitelisted)")
|
||||
->title('Tenant could not be identified on this route because the used column is not whitelisted.')
|
||||
->description('Please add the column to the list of allowed columns in the PathTenantResolver config.');
|
||||
}
|
||||
}
|
||||
|
|
@ -13,8 +13,8 @@ class TenantCouldNotBeIdentifiedByIdException extends TenantCouldNotBeIdentified
|
|||
public function __construct(int|string $tenant_id)
|
||||
{
|
||||
$this
|
||||
->tenantCouldNotBeIdentified("by tenant id: $tenant_id")
|
||||
->title('Tenant could not be identified with that ID')
|
||||
->description('Are you sure the ID is correct and the tenant exists?');
|
||||
->tenantCouldNotBeIdentified("by tenant key: $tenant_id")
|
||||
->title('Tenant could not be identified with that key')
|
||||
->description('Are you sure the key is correct and the tenant exists?');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class TenantCouldNotBeIdentifiedByPathException extends TenantCouldNotBeIdentifi
|
|||
public function __construct(int|string $tenant_id)
|
||||
{
|
||||
$this
|
||||
->tenantCouldNotBeIdentified("on path with tenant id: $tenant_id")
|
||||
->tenantCouldNotBeIdentified("on path with tenant key: $tenant_id")
|
||||
->title('Tenant could not be identified on this path')
|
||||
->description('Did you forget to create a tenant for this path?');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue