-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add cache and session overrides (#50)
* refactor: Allow for the disabling of server resetting on tenancy vacancy * refactor: Refactored cookie helper to backup original session config * chore: Refactor to use service overrides abstraction * feat: Add cache override * chore: Override default database session handler to add where clauses * chore: Add tenanted database session driver * chore: Add session and store overrides to config * build: Make sure test suite runs workbench commands * build(workbench): Make sure workbench publishes the correct assets * refactor: Register service overrides during the boot phase * fix: Disable session override for session resolver * fix: Fix issues with BelongsToManyTenantObserver and new larastan * refactor: Move and rename service override tests and skips tests to be refactored * chore: Ignore same site and secure overrides for session and cookie overrides * fix: Have the cache override use 'override' to provide cache store to be overridden * chore: Make the session identity resolver error out if the session is overridden * refactor: Remove the 'reset services' tenancy option * test: Fix skipped tests that involve service overrides * test: Ignore session and cache from code coverage for now until they can be tested properly
- Loading branch information
Showing
23 changed files
with
1,005 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,9 @@ | |
"phpstan" | ||
], | ||
"test" : [ | ||
"@clear", | ||
"@prepare", | ||
"@build", | ||
"@php vendor/bin/phpunit" | ||
] | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace Sprout\Contracts; | ||
|
||
use Illuminate\Contracts\Foundation\Application; | ||
use Sprout\Sprout; | ||
|
||
/** | ||
* Bootable Service Override | ||
* | ||
* This contract marks a {@see \Sprout\Contracts\ServiceOverride} as being | ||
* bootable, meaning that it can perform actions during the boot stage of the | ||
* framework. | ||
*/ | ||
interface BootableServiceOverride extends ServiceOverride | ||
{ | ||
/** | ||
* Boot a service override | ||
* | ||
* This method should perform any initial steps required for the service | ||
* override that take place during the booting of the framework. | ||
* | ||
* @param \Illuminate\Contracts\Foundation\Application $app | ||
* @param \Sprout\Sprout $sprout | ||
* | ||
* @return void | ||
*/ | ||
public function boot(Application $app, Sprout $sprout): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace Sprout\Contracts; | ||
|
||
/** | ||
* Service Override | ||
* | ||
* This contract marks a class as being responsible for handling the overriding | ||
* of a core Laravel service, such as cookies, sessions, or the database. | ||
*/ | ||
interface ServiceOverride | ||
{ | ||
/** | ||
* Set up the service override | ||
* | ||
* This method should perform any necessary setup actions for the service | ||
* override. | ||
* It is called when a new tenant is marked as the current tenant. | ||
* | ||
* @param \Sprout\Contracts\Tenancy<*> $tenancy | ||
* @param \Sprout\Contracts\Tenant $tenant | ||
* | ||
* @return void | ||
*/ | ||
public function setup(Tenancy $tenancy, Tenant $tenant): void; | ||
|
||
/** | ||
* Clean up the service override | ||
* | ||
* This method should perform any necessary setup actions for the service | ||
* override. | ||
* It is called when the current tenant is unset, either to be replaced | ||
* by another tenant, or none. | ||
* | ||
* It will be called before {@see self::setup()}, but only if the previous | ||
* tenant was not null. | ||
* | ||
* @param \Sprout\Contracts\Tenancy<*> $tenancy | ||
* @param \Sprout\Contracts\Tenant $tenant | ||
* | ||
* @return void | ||
*/ | ||
public function cleanup(Tenancy $tenancy, Tenant $tenant): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.