1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 08:04:03 +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:
lukinovec 2023-08-03 17:51:53 +02:00 committed by GitHub
parent 1d0ca27bc8
commit e3b59ae2b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 33 additions and 32 deletions

View file

@ -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;

View file

@ -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 [
/**

View file

@ -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

View file

@ -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
{

View file

@ -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

View file

@ -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:

View file

@ -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

View file

@ -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.

View file

@ -2,7 +2,7 @@
declare(strict_types=1);
namespace Stancl\Tenancy;
namespace Stancl\Tenancy\Enums;
enum Context
{

View file

@ -2,7 +2,7 @@
declare(strict_types=1);
namespace Stancl\Tenancy;
namespace Stancl\Tenancy\Enums;
enum RouteMode
{

View file

@ -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
{

View file

@ -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.

View file

@ -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

View file

@ -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
{

View file

@ -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.

View file

@ -2,7 +2,7 @@
declare(strict_types=1);
namespace Stancl\Tenancy;
namespace Stancl\Tenancy\Overrides;
use Illuminate\Cache\CacheManager as BaseCacheManager;

View file

@ -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;

View file

@ -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.

View file

@ -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.

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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() {

View file

@ -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;

View file

@ -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;

View file

@ -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) {