mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 12:24:04 +00:00
Improve file structure (#5)
* Add Enums and Overrides folders * Fix code style (php-cs-fixer) --------- Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
This commit is contained in:
parent
1d0ca27bc8
commit
e3b59ae2b5
26 changed files with 33 additions and 32 deletions
|
|
@ -11,7 +11,7 @@ use Stancl\Tenancy\Middleware;
|
|||
use Stancl\JobPipeline\JobPipeline;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Stancl\Tenancy\TenancyUrlGenerator;
|
||||
use Stancl\Tenancy\Overrides\TenancyUrlGenerator;
|
||||
use Illuminate\Support\Facades\Route as RouteFacade;
|
||||
use Stancl\Tenancy\Actions\CloneRoutesAsTenant;
|
||||
use Stancl\Tenancy\Middleware\InitializeTenancyByPath;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
use Stancl\Tenancy\Middleware;
|
||||
use Stancl\Tenancy\Resolvers;
|
||||
use Stancl\Tenancy\RouteMode;
|
||||
use Stancl\Tenancy\Enums\RouteMode;
|
||||
|
||||
return [
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ use Illuminate\Config\Repository;
|
|||
use Illuminate\Routing\Route;
|
||||
use Illuminate\Routing\Router;
|
||||
use Illuminate\Support\Collection;
|
||||
use Stancl\Tenancy\Enums\RouteMode;
|
||||
use Stancl\Tenancy\PathIdentificationManager;
|
||||
use Stancl\Tenancy\RouteMode;
|
||||
|
||||
/**
|
||||
* The CloneRoutesAsTenant action clones
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use Illuminate\Contracts\Broadcasting\Broadcaster;
|
|||
use Illuminate\Foundation\Application;
|
||||
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
|
||||
use Stancl\Tenancy\Contracts\Tenant;
|
||||
use Stancl\Tenancy\TenancyBroadcastManager;
|
||||
use Stancl\Tenancy\Overrides\TenancyBroadcastManager;
|
||||
|
||||
class BroadcastTenancyBootstrapper implements TenancyBootstrapper
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ use Stancl\Tenancy\Contracts\Tenant;
|
|||
class CacheTagsBootstrapper implements TenancyBootstrapper
|
||||
{
|
||||
protected ?CacheManager $originalCache = null;
|
||||
public static string $cacheManagerWithTags = \Stancl\Tenancy\CacheManager::class;
|
||||
public static string $cacheManagerWithTags = \Stancl\Tenancy\Overrides\CacheManager::class;
|
||||
|
||||
public function __construct(
|
||||
protected Application $app
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use Illuminate\Routing\UrlGenerator;
|
|||
use Illuminate\Support\Facades\URL;
|
||||
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
|
||||
use Stancl\Tenancy\Contracts\Tenant;
|
||||
use Stancl\Tenancy\TenancyUrlGenerator;
|
||||
use Stancl\Tenancy\Overrides\TenancyUrlGenerator;
|
||||
|
||||
/**
|
||||
* Makes the app use TenancyUrlGenerator (instead of Illuminate\Routing\UrlGenerator) which:
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ use Illuminate\Routing\Route;
|
|||
use Illuminate\Routing\Router;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Route as RouteFacade;
|
||||
use Stancl\Tenancy\Context;
|
||||
use Stancl\Tenancy\RouteMode;
|
||||
use Stancl\Tenancy\Enums\Context;
|
||||
use Stancl\Tenancy\Enums\RouteMode;
|
||||
|
||||
// todo1 Name – maybe DealsWithMiddlewareContexts?
|
||||
trait DealsWithEarlyIdentification
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ namespace Stancl\Tenancy\Concerns;
|
|||
use Illuminate\Contracts\Http\Kernel;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Route;
|
||||
use Stancl\Tenancy\Context;
|
||||
use Stancl\Tenancy\Enums\Context;
|
||||
use Stancl\Tenancy\Enums\RouteMode;
|
||||
use Stancl\Tenancy\Exceptions\MiddlewareNotUsableWithUniversalRoutesException;
|
||||
use Stancl\Tenancy\Middleware\IdentificationMiddleware;
|
||||
use Stancl\Tenancy\Middleware\PreventAccessFromUnwantedDomains;
|
||||
use Stancl\Tenancy\RouteMode;
|
||||
|
||||
/**
|
||||
* This trait provides methods that check if a middleware's execution should be skipped.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stancl\Tenancy;
|
||||
namespace Stancl\Tenancy\Enums;
|
||||
|
||||
enum Context
|
||||
{
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stancl\Tenancy;
|
||||
namespace Stancl\Tenancy\Enums;
|
||||
|
||||
enum RouteMode
|
||||
{
|
||||
|
|
@ -6,8 +6,8 @@ namespace Stancl\Tenancy\Features;
|
|||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Stancl\Tenancy\Contracts\Feature;
|
||||
use Stancl\Tenancy\Overrides\Vite;
|
||||
use Stancl\Tenancy\Tenancy;
|
||||
use Stancl\Tenancy\Vite;
|
||||
|
||||
class ViteBundler implements Feature
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ declare(strict_types=1);
|
|||
namespace Stancl\Tenancy\Listeners;
|
||||
|
||||
use Illuminate\Routing\Events\RouteMatched;
|
||||
use Stancl\Tenancy\Enums\RouteMode;
|
||||
use Stancl\Tenancy\PathIdentificationManager;
|
||||
use Stancl\Tenancy\RouteMode;
|
||||
|
||||
/**
|
||||
* Remove the tenant parameter from the matched route when path identification is used globally.
|
||||
|
|
|
|||
|
|
@ -11,12 +11,12 @@ use Illuminate\Support\Facades\URL;
|
|||
use Stancl\Tenancy\Concerns\UsableWithEarlyIdentification;
|
||||
use Stancl\Tenancy\Concerns\UsableWithUniversalRoutes;
|
||||
use Stancl\Tenancy\Contracts\Tenant;
|
||||
use Stancl\Tenancy\Enums\RouteMode;
|
||||
use Stancl\Tenancy\Events\InitializingTenancy;
|
||||
use Stancl\Tenancy\Exceptions\RouteIsMissingTenantParameterException;
|
||||
use Stancl\Tenancy\Overrides\TenancyUrlGenerator;
|
||||
use Stancl\Tenancy\Resolvers\PathTenantResolver;
|
||||
use Stancl\Tenancy\RouteMode;
|
||||
use Stancl\Tenancy\Tenancy;
|
||||
use Stancl\Tenancy\TenancyUrlGenerator;
|
||||
|
||||
/**
|
||||
* @see Stancl\Tenancy\Listeners\ForgetTenantParameter
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ use Illuminate\Http\Request;
|
|||
use Stancl\Tenancy\Concerns\UsableWithEarlyIdentification;
|
||||
use Stancl\Tenancy\Concerns\UsableWithUniversalRoutes;
|
||||
use Stancl\Tenancy\Exceptions\TenantCouldNotBeIdentifiedByRequestDataException;
|
||||
use Stancl\Tenancy\Overrides\TenancyUrlGenerator;
|
||||
use Stancl\Tenancy\Resolvers\RequestDataTenantResolver;
|
||||
use Stancl\Tenancy\Tenancy;
|
||||
use Stancl\Tenancy\TenancyUrlGenerator;
|
||||
|
||||
class InitializeTenancyByRequestData extends IdentificationMiddleware implements UsableWithUniversalRoutes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ use Closure;
|
|||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Route;
|
||||
use Stancl\Tenancy\Concerns\UsableWithEarlyIdentification;
|
||||
use Stancl\Tenancy\Context;
|
||||
use Stancl\Tenancy\RouteMode;
|
||||
use Stancl\Tenancy\Enums\Context;
|
||||
use Stancl\Tenancy\Enums\RouteMode;
|
||||
|
||||
/**
|
||||
* todo come up with a better name.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stancl\Tenancy;
|
||||
namespace Stancl\Tenancy\Overrides;
|
||||
|
||||
use Illuminate\Cache\CacheManager as BaseCacheManager;
|
||||
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stancl\Tenancy; // todo new Overrides namespace?
|
||||
namespace Stancl\Tenancy\Overrides;
|
||||
|
||||
use Illuminate\Broadcasting\Broadcasters\Broadcaster;
|
||||
use Illuminate\Broadcasting\BroadcastManager;
|
||||
|
|
@ -2,10 +2,11 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stancl\Tenancy; // todo new Overrides namespace?
|
||||
namespace Stancl\Tenancy\Overrides;
|
||||
|
||||
use Illuminate\Routing\UrlGenerator;
|
||||
use Illuminate\Support\Arr;
|
||||
use Stancl\Tenancy\PathIdentificationManager;
|
||||
|
||||
/**
|
||||
* This class is used in place of the default UrlGenerator when UrlBindingBootstrapper is enabled.
|
||||
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stancl\Tenancy;
|
||||
namespace Stancl\Tenancy\Overrides;
|
||||
|
||||
use Illuminate\Foundation\Vite as BaseVite;
|
||||
|
||||
class Vite extends BaseVite // todo move to a different directory in v4
|
||||
class Vite extends BaseVite
|
||||
{
|
||||
/**
|
||||
* Generate an asset path for the application.
|
||||
|
|
@ -15,11 +15,11 @@ use Illuminate\Support\Facades\Route;
|
|||
use Illuminate\Support\Facades\Storage;
|
||||
use Stancl\Tenancy\Events\TenancyEnded;
|
||||
use Stancl\Tenancy\Jobs\CreateDatabase;
|
||||
use Stancl\Tenancy\TenancyUrlGenerator;
|
||||
use Stancl\Tenancy\Overrides\TenancyUrlGenerator;
|
||||
use Stancl\Tenancy\Events\TenantCreated;
|
||||
use Stancl\Tenancy\Events\TenantDeleted;
|
||||
use Stancl\Tenancy\Events\DeletingTenant;
|
||||
use Stancl\Tenancy\TenancyBroadcastManager;
|
||||
use Stancl\Tenancy\Overrides\TenancyBroadcastManager;
|
||||
use Illuminate\Filesystem\FilesystemAdapter;
|
||||
use Illuminate\Broadcasting\BroadcastManager;
|
||||
use Stancl\Tenancy\Events\TenancyInitialized;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ declare(strict_types=1);
|
|||
use Illuminate\Support\Facades\Event;
|
||||
use Stancl\Tenancy\Events\TenancyEnded;
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
use Stancl\Tenancy\TenancyBroadcastManager;
|
||||
use Stancl\Tenancy\Overrides\TenancyBroadcastManager;
|
||||
use Illuminate\Broadcasting\BroadcastManager;
|
||||
use Stancl\Tenancy\Events\TenancyInitialized;
|
||||
use Stancl\Tenancy\Listeners\BootstrapTenancy;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Routing\Route;
|
||||
use Stancl\Tenancy\RouteMode;
|
||||
use Stancl\Tenancy\Enums\RouteMode;
|
||||
use Stancl\Tenancy\Tests\Etc\Tenant;
|
||||
use Illuminate\Contracts\Http\Kernel;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
use Illuminate\Foundation\Vite;
|
||||
use Stancl\Tenancy\Tests\Etc\Tenant;
|
||||
use Stancl\Tenancy\Vite as StanclVite;
|
||||
use Stancl\Tenancy\Overrides\Vite as StanclVite;
|
||||
use Stancl\Tenancy\Features\ViteBundler;
|
||||
|
||||
test('vite helper uses our custom class', function() {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Stancl\Tenancy\CacheManager;
|
||||
use Stancl\Tenancy\Overrides\CacheManager;
|
||||
use Stancl\Tenancy\Tests\Etc\Tenant;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Stancl\Tenancy\Events\TenancyEnded;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Stancl\Tenancy\RouteMode;
|
||||
use Stancl\Tenancy\Enums\RouteMode;
|
||||
use Illuminate\Contracts\Http\Kernel;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Stancl\Tenancy\Middleware\InitializeTenancyByDomain;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ use Stancl\Tenancy\Exceptions\TenantCouldNotBeIdentifiedByPathException;
|
|||
use Stancl\Tenancy\Exceptions\TenantCouldNotBeIdentifiedOnDomainException;
|
||||
use Stancl\Tenancy\Exceptions\MiddlewareNotUsableWithUniversalRoutesException;
|
||||
use Stancl\Tenancy\Exceptions\TenantCouldNotBeIdentifiedByRequestDataException;
|
||||
use Stancl\Tenancy\RouteMode;
|
||||
use Stancl\Tenancy\Enums\RouteMode;
|
||||
|
||||
test('a route can be universal using domain identification', function (array $routeMiddleware, array $globalMiddleware) {
|
||||
foreach ($globalMiddleware as $middleware) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue