mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 05:14:05 +00:00
Cloning: improve type annotations
This commit is contained in:
parent
197513dd84
commit
535575a007
1 changed files with 28 additions and 4 deletions
|
|
@ -90,9 +90,21 @@ class CloneRoutesAsTenant
|
|||
protected bool $addTenantParameter = true;
|
||||
protected bool $tenantParameterBeforePrefix = true;
|
||||
protected string|null $domain = null;
|
||||
protected Closure|null $cloneUsing = null; // The callback should accept Route instance or the route name (string)
|
||||
|
||||
/**
|
||||
* The callback should accept a Route instance or the route name (string).
|
||||
*
|
||||
* @var ?Closure(Route|string): void
|
||||
*/
|
||||
protected Closure|null $cloneUsing = null;
|
||||
|
||||
/** @var ?Closure(Route): bool */
|
||||
protected Closure|null $shouldClone = null;
|
||||
|
||||
/** @var list<string> */
|
||||
protected array $cloneRoutesWithMiddleware = ['clone'];
|
||||
|
||||
/** @var list<string> */
|
||||
protected array $addTenantMiddleware = ['tenant'];
|
||||
|
||||
public function __construct(
|
||||
|
|
@ -155,6 +167,8 @@ class CloneRoutesAsTenant
|
|||
* The tenant middleware to be added to the cloned route.
|
||||
*
|
||||
* If used with early identification, make sure to include 'tenant' in this array.
|
||||
*
|
||||
* @param list<string> $middleware
|
||||
*/
|
||||
public function addTenantMiddleware(array $middleware): static
|
||||
{
|
||||
|
|
@ -171,7 +185,11 @@ class CloneRoutesAsTenant
|
|||
return $this;
|
||||
}
|
||||
|
||||
/** Provide a custom callback for cloning routes, instead of the default behavior. */
|
||||
/**
|
||||
* Provide a custom callback for cloning routes, instead of the default behavior.
|
||||
*
|
||||
* @param ?Closure(Route|string): void $cloneUsing
|
||||
*/
|
||||
public function cloneUsing(Closure|null $cloneUsing): static
|
||||
{
|
||||
$this->cloneUsing = $cloneUsing;
|
||||
|
|
@ -179,7 +197,11 @@ class CloneRoutesAsTenant
|
|||
return $this;
|
||||
}
|
||||
|
||||
/** Specify which middleware should serve as "flags" telling this action to clone those routes. */
|
||||
/**
|
||||
* Specify which middleware should serve as "flags" telling this action to clone those routes.
|
||||
*
|
||||
* @param list<string> $middleware
|
||||
*/
|
||||
public function cloneRoutesWithMiddleware(array $middleware): static
|
||||
{
|
||||
$this->cloneRoutesWithMiddleware = $middleware;
|
||||
|
|
@ -190,7 +212,9 @@ class CloneRoutesAsTenant
|
|||
/**
|
||||
* Provide a custom callback for determining whether a route should be cloned.
|
||||
* Overrides the default middleware-based detection.
|
||||
* */
|
||||
*
|
||||
* @param Closure(Route): bool $shouldClone
|
||||
*/
|
||||
public function shouldClone(Closure|null $shouldClone): static
|
||||
{
|
||||
$this->shouldClone = $shouldClone;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue