* Add &Model to docblock
* Fix code style (php-cs-fixer)
* Only delete synced resource if the central resource shouldSync
* Add central resource detached event and listener
* Add SyncedTenant interface
* Use the event & listener in the test file
* Add getGlobalIdentifierKey(Name) to TenantMorphPivot
* Refactor TriggerSyncingEvents
* Fix code style (php-cs-fixer)
* Test queueing the detaching listener
* Move finding the central resource into the event, naming changes
* Fix code style (php-cs-fixer)
* Simplify listener code
* Refactor detaching logic
* Create tenant resource after attaching central to tenant, test queueing related listener
* Delete dd()
* Fix code style (php-cs-fixer)
* Move triggerAttachEvent from SyncMaster
* Update attach event-related code
* Move findResource from SyncedTenant to the pivot trait
* Add annotation
* Update annotation
* Simplify getAttributesForCreation in CreateTenantResourceFromSyncMaster
* Update naming
* Add tenant trait for attaching/detaching resources
* Update test names
* Move creation attribute parsing method to trait
* Rename variable
* Fix code style (php-cs-fixer)
* Delete complete to-do
* Delete event comment
* Rename event property
* Find tenant resource in detach listener
* Use global ID key of tenant resource in cascade deletes listener
* Use global ID key name of the central resource while creating/deleting tenant resources
* Add getSyncedCreationAttributes example in the annotation
* Fix inconsistencies in SyncedTenant methods
* Improve annotation
* Don't return the query in `$scopeGetModelQuery`
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* Fix code style (php-cs-fixer)
* Update scoping getModel query
* Only use detach event instead of using both detach and delete events, refactor code
* Test that detaching tenant from a central resource doesn't affect other tenants
* Delete extra imports
* Fix code style (php-cs-fixer)
* Add PivotWithRelation, test attaching/detaching resources without polymorphic relations
* Refactor TriggerSyncingEvents to work with non-polymorphic relations too
* Fix code style (php-cs-fixer)
* Rename synced resource changed event, fix tests
* Enforce passing Tenant&Model to attach/detach events
* Prevent firing saved event automatically in CreateTenantResource
* Improve TriggerSyncingEvents trait
* Delete unused import
* Make TriggerSyncingEvents methods non-static, improve annotations
* Pass saved model to event
* Move attach/detach queueing tests to ResourceSyncingTest, pass models instead of IDs to attach/detach
* Move events to ResourceSyncing\Events
* Fix code style (php-cs-fixer)
* Use SerializesModels in queueable listeners instead of events
* Delete redundant $shouldQueue setting
* Rename listener, test cascade deletes from both sides of many-to-many
* Move creation attributes-related code to a separate test file, improve comments (wip)
* Improve comments, fix variable name capitalization
* Delete tracing comma
* Extract duplicate code into a trait
* Don't accept nullable tenant in SyncMasterDeleted
* Fix annotation
* Fix code style (php-cs-fixer)
* Update annotation
* Fix PHPStan error
* Fix annotation
* Update comments and test naming
* Move triggerDeleteEvent to CascadeDeletes interface
* Rename test file
* Import TenantPivot in Tenant class (tests/Etc)
* Add central resource not available in pivot exception
* Rename SaveSyncedResource to UpdateOrCreateSyncedResource
* Add new events and listeners to TSP stub
* Improve comments and naming
* Only keep SerializesModels in classes that utilize it
* Use tenant->run()
* Import events in stub
* Move RS listeners to separate namespace, use `Event/`Listener/` in stub for consistency
* Fix code style (php-cs-fixer)
* Fix namespace changes
* Use cursor instead of get
* Update src/ResourceSyncing/ParsesCreationAttributes.php
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* Update naming, structure (discussed on Discord)
* Update uses in in test file
* remove double ;;
* Add comments
* Test if static properties work fine with queueable listeners
* Update $shouldQuery test
* Update creation attributes
* Work on updating the tests
* Make synced attributes configurable using static properties
* Update resource syncing tests
* Get rid of mixed attribute classes
* Get rid of TenantUserWIthCreationAttributes
* Fix imports
* Get rid of the conditionally synced classes, improve tests
* Simplify resource creation tests (only test the more complex cases instead of each case - if the complex case works, the simpler cases work too)
* Clean up ResourceSyncingTest (mostly duplicate tests that were already in AutomaticResourceCreationTest)
* Simplify class naming in polymorhpic tests
* Move automatic resource creation tests to ResourceSyncingTest
* Test that the sync event doesn't get triggered excessively
* Only trigger the sync event if the synced attributes were changed or if the resource was recently created
* Update synced attribute instead of unsynced in test
* Fix sync event test
* Update static property redefining test
* Use getGlobalIdentifierKeyName() instead of hardcoding the key name
* Delete static properties from the ResourceSyncing trait
* Reuse user classes in polymorphic tests
* Update tests/ResourceSyncingTest.php
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* Use the default tenants() method in central user, override the default in ResourceSyncingTest
* Use BelongsToMany as tenants() return type
* Fix code style (php-cs-fixer)
* Delete extra static property from trait
* Delete duplicate events/listeners from TSP stub
* Delete weird expectation, use $model->trashed()
* Change ResourceUser to TenantUser
* Add defaults for getGlobalIdentifierKey(Name)
* Use singular tenant in DeleteResourceInTenants name
* Rename getSyncedCreationAttributes to getCreationAttributes
* Fix comma position in comment
* minor fixes in traits and interfaces
* Fix code style (php-cs-fixer)
* Correct comment
* Use $tenant->run()
* Update scopeGetModelQuery annotation
* Use static property for testing shouldSync
* Improve test
* Get rid of datasets
* Add trashed assertions
* Always merge synced attributes with the creation attributes during parsing
* Update creation attributes in test's beforeEach
* Use only the necessary creation attributes (no need to include the synced attributes because they get merged automatically)
* Rename ResourceTenant to MorphTenant
* Add TriggerSyncingEvents docblock
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* Add force deletes test
* Fix code style (php-cs-fixer)
* Delete pivot if it can't access the resource class
* Make parseCreationAttributes more readable
* Comment out setting $scopeGetModelQuery in the stub
* Add @var annotations to bootTriggerSyncingEvents
* Fix attach()/detach() exception test
* Interrupt creation of broken pivots instead of deleting the pivots at a later point
* Add more comments
* Update CreateTenantResource comment
* Assert that forceDelete() doesn't affect other tenant resources
* Rename test
* Correct with() array formatting
* Expand test with soft deletes
* Merge SyncedResourceSaved tests
* Improve naming, comments and minor details in the assertions
* Move test
* Fix failing test
* Delete duplicate test
* Minor test improvement
* Delete duplicate test
* Improve old test
* Minor test improvement
* Improve event test
* Improve tests (naming, code, comments)
* Delete extra test, add comments to the larger test
* Refactor central -> tenant attach() test
* Apply changes from central -> tenant attach() test on tenant -> central test
* Fix assertions in central -> tenant
* Correct comment and assertion
* Refactor tenant -> central attach() test
* Fix inconsistency
* Delete unused import
* Add comments
* Update polymorphic test names
* Rename polymorphic tests
* Update listener test name
* Delete redundant tenant ID assignments
* Improve test names
* Move polymorphic tests to ResourceSyncingTest
* Mention alternative solutions in CentralResourceNotAvailableInPivotException
* Add comments
* Update test comments
* minor changes to tests + review comments
* Delete extra tests, update comments
* Remove unneeded part of test
* Fix comment
* Improve comments
* Add test for companies() realationship accessibility
* Update test name
* Complete to-do, add comment
* Improve naming and comments (resolve some priority reviews)
* Move test
* Comment, resolve to-dos
* Add low-level pivot assertions
* Restore trashed resources if the central resource got restored, try improving tests
* Fix code style (php-cs-fixer)
* Dekete redundnat unsynced comments
* Add to-do, test WIP
* Fix restoring logic
* Update todo
* Add todo to fix phpdoc
* Fix code style (php-cs-fixer)
* PHPStan error fix wip
* Fix PHPStan error
* Add regression test
* Delete unused trait
* Add and test restoring WIP
* Fix code style (php-cs-fixer)
* Add to-do
* Delete comment from test
* Focus on restoring in the restore test
* Improve maming
* Fix stub
* Delete redundant part of test
* Delete incorrect test leftover
* Add triggerRestoredEvent
* Fix restore test
* Correct tests and restore(() logic
* Fix code style (php-cs-fixer)
* Check if SoftDeletes are used before firing SyncMasterRestored
* Fix comment
* Revert restore action changes (phpstan errors)
* Delete CascadeDeletes interface
* Remove CascadeDeletes from most of the tests
* Fix code style (php-cs-fixer)
* Rename tests
* Fix restoring + tests WIP
* Fix restoring
* Fix restoring tests
* Fix code style (php-cs-fixer)
* Test that detaching force deletes the tenant resources
* Implement cacscade force deleting
* Delete redundant changes
* Fix typo
* Fix SyncMaster
* Improve test
* Add force deleting logic back and fix tests
* Improve comment
* Delete extra assertion
* Improve restoring test
* Simplify assertion
* Delete redundant query scoping from test
* Test restore listener queueing
* use strict in_array() checks
* fix phpstan errors
---------
Co-authored-by: lukinovec <lukinovec@gmail.com>
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
* Resolve delete tenant storage todo
* Delete outdated todo (resolved in #25)
* Delete resource syncing todo (resolved in #11)
* Make it clear that getArgsForTenant() is used during cache invalidation
* Delete redundant __call() and __callStatic() annotations
* Fix code style (php-cs-fixer)
* Revert %tenant_id% to-do removal
* Test all cached resolvers instead of just the domain one
* Make docblock more concise, delete renaming to-do (the name seems fine)
* Fix method in tests
* If route is the only resolver arg, use the tenant as the cache key instead of encoded route instance
* Resolve to-do
* make docblock more clear
* Add comments to getResolverArgument()
* Rename $id to $tenantKey
* Fix code style (php-cs-fixer)
* Add regression test for forgetting tenant parameters of cached tenants
* Forget route parameter when tenant gets resolved
* Add parameter type
* Simplify getCacheKey()
* Resolvers wip
* Resolvers wip
* Fix code style (php-cs-fixer)
* Bring back the route instance check to getCacheKey, fix test
* add todo
* add assertion
---------
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
Co-authored-by: Samuel Štancl <samuel@archte.ch>
* Make universal routes work for controller middleware
* add a fallback
---------
Co-authored-by: chillbram <7299762+chillbram@users.noreply.github.com>
Co-authored-by: Samuel Štancl <samuel@archte.ch>
* Add permission controleld MSSQL DB manager
* Fix code style (php-cs-fixer)
* Fix manager
* Don't change databases when creating MSSQL user
* Test permission controlled MSSQL DB manager
* Fix code style (php-cs-fixer)
* Delete redundant config resetting in tests
* Grant user permissions insteead of making the user the database owner
* Test that user gets created in the tenant DB
* Test that the correct permissions are granted to the DB users
* Fix code style (php-cs-fixer)
* Update config comment
* Fix typo
* Add perm controlled sqlsr db manager to test dataset
* Close all connections before deleting MSSQL DBs
* Fix code style (php-cs-fixer)
* Add explanation to deleteDatabase()
* Update tests/DatabaseUsersTest.php
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* Fix code style (php-cs-fixer)
---------
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* Add origin ID MW
* Test origin ID MW
* Test origin ID MW with early identification
* Fix code style (php-cs-fixer)
* Fix PHPStan errors
* Add getDomain() to domain ID MW, simplify origin ID MW
* Fix code style (php-cs-fixer)
* Rename InitializeTenancyByOrigin to InitializeTenancyByOriginHeader
* Add onFail test
* Stop throwing the exception in getDomain()
* FIx merge
* Improve origin identification test file
* Clean up test
---------
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
* Stop bypassing tenancy initialization when host is central domain in domain ID MW
* Delete dataset for testing global domain ID MW + route-level prevent access MW
* Provide ID MW statically in TenantAssetController
* Fix code style (php-cs-fixer)
---------
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
* pass BroadcastManager to override closures
* Improve the broadcaster override syntax in the bootstrapper test
* remove unnecessary return
---------
Co-authored-by: lukinovec <lukinovec@gmail.com>
* Use data_get() to allow mapping nested tenant attributes to mail config
* Fix code style (php-cs-fixer)
* Test the data_get() change
* Improve code, add info to docblock
---------
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
* Add SingleDomainTenant
* Add logic for single domain tenants
* Test that the single domain approach works (wip)
* Fix code style (php-cs-fixer)
* Simplify SubdomainTest tests
* Add single domain tenant conditions to DomainTenantResolver
* Test single domain tenants in resolver test
* Fix test name typo
* Improve runUsingBothDomainApproaches()
* Delete extra tenancy()->end()
* Test early identification with both domain approaches
* Test that things work with both domain approaches in the rest of the tests
* Fix falsely passing test
* Fix PHPStan errors
* Change SingleDomainTenant to a contract, add SingleDomainTenant test model
* Fix TenantList domainsCLI()
* Improve setCurrentDomain() check
* Fix code style (php-cs-fixer)
* Add annotation
* Revert getCustomColumns() change
* Add comments
* Use the domain returned by the closure in runUsingBoth..()
* Delete `migrate` from test
* Improve test names
* Use variable instead of repeating the same string multiple times
* Update comment
* Add comment
* Clean up PreventAccess test
* Don't assign domain to a single-use variable
* Update comments
* Uncomment datasets
* Add todo
* Fix user impersonation test
* Don't specify tenant key when creating tenant in runUsingBoth..()
* Improve universal route test
* Improve `runUsingBothDomainApproaches()`
* Add tests specific to single domain tenants
* Get rid of the runUsingBothDomainApproaches method
* Add test file specific for the single domain tenant feature
* Rename test
* Make getCustomColumns() function static
* Positiopn datasets differently
* Fix early id test
* Add prevent MW to route MW in test
* Fix single domain tenant tests
* Delete SingleDomainTenantTest (CI testing)
* Add the test file back
* TUrn APP_DEBUG on temporarily
* Turn debug off
* Try creating tenant with non-unique domain (CI testing)
* dd duplicate tenant records
* Revert testing change
* Make SingleDomainTenant not extend base tenant (VirtualColumn issues)
* Fix early id test
* add todo
* Use dev-master stancl/virtualcolumn
* Make SingleDomainTenant extend the tenant base model
* remove todo
* Clean up EarlyIdentificationTest changes
* Finish test file cleanup
* Fix test
* improve test
---------
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* Make asset_helper_tenancy false by default
* Make tenant_asset() respect ASSET_URL
* Set asset helper tenancy to true in tests where needed
* If the `asset_helper_tenancy` key is missing, default to false in filesystem bootstrapper
* Make temporary clone action changes
* Make tenancy asset route universal
* Make the asset controller's asset method behave differently if path ID MW is the default
* Test that asset helper works with path identification
* Fix code style (php-cs-fixer)
* Delete path traversal attack prevention
* Fix code style (php-cs-fixer)
* Skip cloning of stancl.tenancy.asset route in some tests
* Fix code style (php-cs-fixer)
* Clone asset route in TSP stub
* Add cloning only the passed route
* Clone asset route in tenant asset test beforeEach
* Skip asset route cloning by default
* Fix typo
* Change public method back to protected
* Remove cloning of specific routes, skip cloning routes flagged as tenant
* Delete constructor from asset controiler, change asset method to invoke
* Update asset route registration, add prefixed asest route for path identification
* Use default middleware from config instead of `tenancy()->defaultMiddleware()`
* Delete old code from TSP stub
* Revert TSP stub change
* Revert FilesystemTenancyBootstrapper changes
* Suffix asset url in tenant_asset()
* Simplify `tenant_asset()`
* Ensure the base asset url is always suffixed with '/'
* remove unnecessary ?? false
---------
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* Allow cloning routes when only kernel identification is used, explicitly enable specific cloning modes
* Explicitly enable needed clone modes in tests, use "clone" instead of "reregister"
* Fix code style (php-cs-fixer)
* Use "cloning" instead of "re-registration" in UniversalRouteTest
* Only clone routes using path identification
* Revert clone mode changes
* Fix code style (php-cs-fixer)
* Update comment
* Skip cloning 'stancl.tenancy.asset' by default
* Decide which routes should get cloned in the filtering step, improve method organization
* Return `RouteMode::UNIVERSAL` in getMiddlewareContext if route is universal
* Give universal route the path ID MW so that it gets cloned
* Fix code style (php-cs-fixer)
* Simplify UsableWithEarlyIdentification code
* Handle universal route mode in ForgetTenantParameter
* Fix code style (php-cs-fixer)
* Rename getMiddlewareContext to getRouteMode
* Append '/' to the route prefix
* Rename variable
* Wrap part of condition in parentheses
* Refresh name lookups after cloning routes
* Test giving tenant flag to cloned routes
* Add routeIsUniversal method
* Correct ForgetTenantParameter condition
* Improve tenant flag giving logic
* Improve test name
* Delete leftover testing code
* Put part of condition into `()`
* Improve CloneRoutesAsTenant code + comments
* Extract route mode-related code into methods, refactor and improve code
* Improve ForgetTenantParameter, test tenant parameter removing in universal routes
* Fix code style (php-cs-fixer)
* Fix test
* Simplify adding tenant flag
* Don't skip stancl.tenancy.asset route cloning
* clean up comment
* fix in_array() argument
* Fix code style (php-cs-fixer)
---------
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* Test that the context is central after jobs get processed
* Revert to central context when jobs get processed, delete `$previousTenant` logic
* Test that the tenant connections get closed after jobs get processed
* Bring back the previous tenant logic
* Adapt tests to the previous tenant logic
* Delete assertion
* Test if Storage::url() works correctly after reverting to central context
* Fix typo in code
* Access originalPaths using dot notation using `data_get()`
* Use "clone" instead of "re-register" in UniversalRouteTest
* Fix `$shouldCloneRoute` condition, improve tenant flagging logic
* Use clone instead of reregister in stub
* Update url binding bootstrapper test
* Fix parent::temporarySignedRoute() call
* Add universal route tests for all identification types
* Improve determineContextFromRequest()
* Add setting `TenancyUrlGenerator::$prefixRouteNames` to true in TSP stub
* Delete seemingly redundant test (making one route universal won't make all routes universal in any case)
* Use collection syntax in ReregisterUniversalRoutes
* Improve comments
* Add domain identification MW annotation
* Update condition in GloballyUsable
* Set `tenancy.bootstrappers` instead of adding the bootstrappers using `tenancy.bootstrappers.x`, move test
* Revert GloballyUsable condition change
* Delete assigning bootstrappers to tenancy.bootstrappers.x
* Exclude cache prefixing bootstrapper from the initial configuration
* Fix test
* Unset bypass parameter
* Set static kernel identification-related properties in TestCase
* Update bootstrapper name in annotation
* Move unset() into a condition
* Update TenancyUrlGenerator condition
* Set static properties without instantiating Tenancy
* Fix unsetting bypass parameter
* formatting changes
* add a comment
* improve docblock
* add docblock to TenancyUrlGenerator [ci skip]
* docblock changes [ci skip]
* Update TenancyUrlGenerator (rename variable, allow bypassing prefixing temporarySignedRoute name)
* Improve determineContextFromRequest
* Only return the new url generator instance when extending 'url' in UrlBindingBootstrapper
* Check route's MW groups for the path ID MW
* Remove extra imports from config
* Rename MiddlewareContext to Context, add condition for skipping ID MW
* Set only the needed bootstrappers in TestCase
* Fix code style (php-cs-fixer)
* Remove condition
* Use correct return type
* Fix PHPStan issue
* Update comment
* Check for tenant parameter instead of prefix
* Update shouldBeSkipped condition for universal routes
* Don't remove the 'universal' MW group after route re-registration, update test
* Fix code style (php-cs-fixer)
* Fix typo
* Add test for mixing placement of access prevention and identification MW
* Add test for mixing placement of access prevention and identification MW
* Update docblock
* Add setting the session and key resolvers in UrlBindingBootstrapper (required with LW file uploads)
* Update stub
* Update variable name in route reregistering action
* Add trailing comma
* Fix code style (php-cs-fixer)
* Require routes using path identification to be flagged as tenant in order to be recognized as tenant routes
* Add tenant flag while re-registering routes
* Update determineContextFromRequest condition (wip)
* Fix code style (php-cs-fixer)
* Update the middleware context logic so that universal routes have to be flagged as tenant instead of just having ID MW
* Update path identification condition
* Fix re-registering the LW localized route (add 'tenant' MW)
* Update docblock
* Simplify LW route re-registration
* Add comment
* Update comment
* Simplify determineContextFromRequest, add comment
* Improve stub
* Add skipRoute method + test
* Fix typo
* Update assets/TenancyServiceProvider.stub.php
* Update src/Concerns/DealsWithEarlyIdentification.php
* Fix typo
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* Improve comment
* Update test structure
* Restructure Fortify test
* code style
* Fix typo
* Update ReregisterUniversalRoutes annotation
* Only prefix route name if it wasn't already prefixed
* Add todo@docs
* Delete `Tenancy::$kernelAccessPreventionSkipped` and related logic
* Delete test tenant cleanup
* Test MW group unpacking, restructure and improve test
* Test that tenancy isn't initialized after visiting a central route with the tenant parameter
* Delete "in both central and tenant contexts" from test names
* Test that re-registering works with controllers too
* Set misc route properties during re-registering
* Determine context instead of guessing, update universal route tests
* Use randomly generated tenant ID instead of hardcoding `acme`
* Remove setting route validators
* Rename and update determine context method, add comments
* Update ForgetTenantParameter annotation
* Add comment
* Delete comment, delete variable assignment
* Update early domain identification test
* Improve domain identification tests (test defaulting accurately)
* Improve readability
* Simplify domain early ID test
* Use randomly generated tenant instead of 'acme'
* Simplify request data ID test, use random tenant instead of 'acme'
* Simplify defaulting domain identification test
* Use RouteFacade alias for the Route facade, improve test code
* Add defaulting to the request data and path ID tests
* Merge path identification tenant parameter removal tests, clean up
* Correct wording
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* Delete debugging things from UniversalRouteTest
* Update annotation
* Add `// Creates a matrix`
* Improve comment wording
* Add MiddlewareUsableWithUniversalRoutes, refactor code accordingly
* Fix code style (php-cs-fixer)
* Delete debugging leftovers
* Delete unused import
* Update universal route GloballyUsable condition
* Don't implement the universal route interface in access prevention MW
* Check if request host is in the central domains in domain ID MW
* Test universal routes with domain identification without access prevent MW
* Test that universal routes work only with identification MW implementing the universal route interface
* Fix code style (php-cs-fixer)
* Rename GloballyUsable to UsableWithEarlyIdentification
* Fix annotation
* Update requestHasTenant annotations
* Update comment
* Add `with()` comments
* Add with() comments where missing
* Rename interface, update/add comments
* Rename exception, update its default message
* Fix code style (php-cs-fixer)
* Fix interface name
* Delete redundant code from subdomain ID MW
* Change domainOrSubdomain ID MW so that instead of passing the identification to other MWs, it happens in the domainOrSubdomain MW
* Test domainOrSubdomain identification with universal routes
* Fix code style (php-cs-fixer)
* Rename universal routes interface
* Fix code style (php-cs-fixer)
* Try explaining forgetting the tenant parameter better
* update interface name reference
* uncouple example from query parameters
* Update ForgetTenantParameter.php
* Update ForgetTenantParameter annotation
* Check both routeHasMiddleware and routeHasIdentificationMiddleware in the route MW detection test
* Hardcode tenant subdomain
* Delete redundant event listening code
* Delete unused imports
* Delete misuse of `tenancy()->getMiddlewareContext()` from conditions
* Delete unused variable
* Update comment
* Correct request data identification test (defaulting)
* Fix defaulting in path id test
* Move default route context configuration in domian id test
* Rename and update the tenant parameter test
* Delete extra tenant parameter test
* Use `tenant-domain.test` instead of `127.0.0.2`
* Add `default_to_universal_routes` config key
* Deal with defaulting to universal routes in the reregistering action
* Update logic to make defaulting to universal routes possible
* Test defaulting to universal routes
* Fix code style (php-cs-fixer)
* Delete extra tests
* Delete "without access prevention" from datasets
* Add defaulting to universal routes to datasets
* Override universal flag by central/tenant flag
* Add universal flag overriding test
* Update "a route can be universal in both route modes" so that the name corresponds with the tested thing
* Ignore the PHPStan error
* Reset `InitializeTenancyByPath::$onFail` in PathIdentificationTest
* Simplify expression
* Use 'Tenancy (not) initialized.' in instead of `tenant()?->getTenantKey()` for better assertions
* Properly test removing tenant parameter
* Reset static properties in tests
* Correct comments in EarlyIdentificationTest
* Add comment
* Add detail to annotation
* Throw exception if payload isn't string or null in request data ID MW
* Fix code style (php-cs-fixer)
* Delete static `$kernelIdentificationSkipped` property, use `$request->attributes` instead
* Use 'default_route_mode' instead of 'default_to_tenant/universal_routes'
* Fix code style (php-cs-fixer)
* Make path identification MW, tenantParameterName and tenantRouteNamePrefix configurable in ReregisterUniversalRoutes
* Delete unused import
* Add `$passTenantParameterToRoute` to TenancyUrlGenerator
* Use `$passTenantParameterToRoute` in BootstrapperTest
* Bypass tenant parameter passing
* Improve TenancyUrlGenerator so that both ID methods work
* Fix code style (php-cs-fixer)
* Improve TenancyUrlGenerator readability
* Add modifyBehavior() to TenancyUrlGenerator
* Fix code style (php-cs-fixer)
* Improve comment
* Toggle route name prefixing in path/request data ID MW (route-level identification)
* Fix code style (php-cs-fixer)
* Add path identification MW config key, add `getTenantParameterName()` to ForgetTenantParameter
* Fix code style (php-cs-fixer)
* Fix modifyBehavior and routeBehaviorModificationBypassed
* Add type to `$parameters` parameter
* Split modifyBehavior into two methods, don't pass name and parameters by reference
* Update UrlBindingBootstrapper annotation
* Correct naming in tests (request data -> query string identification)
* Add info to annotation
* Pass arrays to the behavior modification methods instead of `mixed`
* Fix default value of static property in Fortify bootstrapper
* Fix code style (php-cs-fixer)
* Correct annotation
* Enable prefixing routes directly using path identification MW
* Test re-registration of routes with path ID MW
* Prefix names of routes directly using path ID MW
* Fix code style (php-cs-fixer)
* Add Livewire v3 integration example to TSP stub
* Prefix route name only if it's not prefixed already
* Rename ReregisterUniversalRoutes to ReregisterRoutesAsTenant
* Fix code style (php-cs-fixer)
* Improve ReregisterRoutesAsTenant
* Add/update TenancyUrlGenerator docblocks
* Update action name in comments/test names
* Update reregister action annotation
* Delete unused imports
* Improve comments
* Make method protected
* Improve TenancyUrlGenerator code
* Test bypass parameter removal
* Fix comment
* Update annotation
* Improve shouldReregisterRoute
* Fix typo, delete redundant comment
* Improve skipRoute
* Improve shouldBeSkipped
* Add and test `$passTenantParameterToRoutes`
* add a comment
* Fix typo in comment
* Pass array as $parameters in prepareRouteInputs
* Make path_identification_middleware an array
* Fix code style (php-cs-fixer)
* Fix ReregisterRouteAsTenant
* Move tenantParameterName and tenantRouteNamePrefix getting to PathIdentificationManager
* Make PathIdentificationManager properties `Closure|null`
* Fix code style (php-cs-fixer)
* Fix PathIdentificationManager
* Update comments
* Use foreach for dataset definition
* Extract repetitive inGlobalStack and routeHasMiddleware calls
* Refactor PathIdentificationManager
* Update TenancyUrlGenerator annotation
* Add $skippedRoutes, refactor ReregisterRoutesAsTenant
* Improve reregisterRoute
* Update re-register action annotation
* update test name
* Make PathIdentificationManager methods static again, update comments
* Add test comment
* Update ForgetTenantParameter annotation
* Improve route re-registration condition, add comment
* Change "re-register" to "clone"
* minor code improvements
---------
Co-authored-by: lukinovec <lukinovec@gmail.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
* cache prefix
* prefix cache bootstrapper and tests
* remove comment
* DI app
* cache prefix base from config
* Create PrefixCacheBootstrapperTest.php
* remove `null` check
* fix phpstan error
* Update PrefixCacheTenancyBootstrapper.php
* Update PrefixCacheBootstrapperTest.php
* add comments
* Update PrefixCacheTenancyBootstrapper.php
* Update PrefixCacheBootstrapperTest.php
* Update config.php
* test names grammar
* user `getTenantKey` method
* assert tenants' data is accessible using the prefix from the central context
* remove unused line
* use proper DI
* build prefix using original prefix
* fix prefix test according to prefix changes
* fix test
* CacheManager dependency injection test
* CacheService class as singleton
* introduce second tenant in test
* use Repository in service class DI
* Update CacheAction.php
* Rename CacheAction to CacheService
* Update prefix bootstrapper and test (`setStore()` in CacheManager and Repository needed)
* Add macro
* Fix code style (php-cs-fixer)
* Simplify cache store refreshing
* Make Tenancy override CacheManager
* Update CacheManager, add refreshStore()
* Fix code style (php-cs-fixer)
* Uncomment cache tagging
* Revert condition in CacheManager to avoid excessive nesting
* Move `Cache::macro()` to a slightly more appropriate place
* Fix code style (php-cs-fixer)
* Use better class for the macro
* Toggle cache tags
* Make CacheManager::$addTags default to `true`
* Add changes to PR to Laravel
* Fix code style (php-cs-fixer)
* Revert changes, add comment
* Add test
* Make `$cache` non-nullable
Co-authored-by: Samuel Štancl <samuel@archte.ch>
* Add and test `nonTenantCacheDrivers`
* Add nonTenantCacheDrivers check
* Test that the prefix stays the same
* Change nonTenantCacheDrivers to tenantCacheStores
* Remove redundant CacheManager extend() call
* Make 'redis' the only tenant cache store in beforeEach, test that tenantCacheStores works
* Remove unused import, change word
* Make CacheService a singleton in a test
* Update test name
* Remove group('prefix')
* Rename CacheManagerService
* Improve specific cache store in a service test
* Improve comment
* Improve tests
* Use my Laravel fork
* Fix code style (php-cs-fixer)
* Downgrade Laravel
* Upgrade Laravel
* Hint Repository implementation instead of contract
* Fix types
* Fix code style (php-cs-fixer)
* Fix test
* Use Laravel fork in ci.yml
* use dev-master before our changes are released in L10
* remove laravel fork from repositories
* use 10.x-dev instead of master
* remove L9 support
* 10.x-dev (fix conflict resolution)
* use the laravel version from the ci matrix for the phpstan job as well
* Revert "use the laravel version from the ci matrix for the phpstan job as well"
This reverts commit 5f3079d2ff.
* Test that non-default stores get prefixed too
* Use new Laravel release, remove L9 support
* Complete L9 support removal
* Specify 10.1.1 as the minimal Laravel version in ci.yml
* Use 10.x-dev
* Prefix all cache stores specified in `$tenantCacheStores`
* Update Laravel
* Use tmpfs in docker-compose
* Add customizing cache store prefixes
* Test cache prefixing customization
* Fix code style (php-cs-fixer)
* Update ci.yml
* Delete tmpfs from docker-compose.yml (there were no benefits)
* Use default prefix generator inline, delete the 'default' key logic
* Fix original prefix logic
* Update tests
* Delete CacheTenancyBootstrapper
* Reset static properties in afterEach
* Use `$this->config` instead of `config()`
* Disable cache tagging by default, add CacheTagBootstrapper
* Fix code style (php-cs-fixer)
* Rename bootstrapper
* Improve CacheManager
* Move logic from separate method to __call
* Make original prefixes customizable
* Add info in comment
* Add defaultPrefix property
* Use `$this->app` instead of `app()`
* Rename bootstrapper
* Fix code style (php-cs-fixer)
* Use a single original prefix
* Update prefix generator logic + tests
* Correct `$addTags` reset in a test
* Update cache tests so that both prefixing and tagging is covered
* Simplify cache tests
* Delete afterEach
* Small testing improvements
* Set `cache.default` in beforeEach
* Update cache prefixing and tests
* Add assertion
* Refactor assertion
* Refactor assertions
* Delete TTL from cache put calls
* Add re-initialization cache assertion
* Assert that cache is null from the beginning
* Merge the tenantCacheStores tests
* Fix formatting
* Improve test name
* Improve tests
* Add cache manager config key
* Fix code style (php-cs-fixer)
* Update defaulting test
* Add todo
* Update comments
* Extract duplicate assertions into a closure
* Update comment
* Add assertions + comment
* Delete redundant config put calls
* Use `tenancy.cache.manager` config instead of `Stancl\Tenancy\CacheManager`
* Change setting to assertion, add comment
* Inline variable & config key assignment
* Delete `cache.default` assertion
* Override cache manager only in CacheTagsBootstrapper
* Fix code style (php-cs-fixer)
* Prefix both drivers by default, add assertions for the second driver where missing
* Clean up global state (static properties) in before/afterEach
* Add docblock to tags bootstrapper
* Delete extra dependency
* Add `illuminate/support` dependency back
* Use `$addTags` approach again
* Fix code style (php-cs-fixer)
* Revert "Fix code style (php-cs-fixer)"
This reverts commit ea805fa231.
* Revert "Use `$addTags` approach again"
This reverts commit 8f5a4e4eb6.
* Add commented CacheTagsBootstrapper with info to the bootstrappers config
* Delete legacy bootstrapper from the bootstrappers config, add info to the bootstrapper's docblock
* Delete "?" from `tenant()?->getTenantKey()
* call generatePrefix() on $bootstrapper
* misc improvements
---------
Co-authored-by: lukinovec <lukinovec@gmail.com>
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel@archte.ch>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* Add BroadcastTenancyBootstrapper and TenancyBroadcastManager
* Fix code style (php-cs-fixer)
* Bind original BroadcastManager again on `revert()`
* Fix code style (php-cs-fixer)
* Move manager to correct directory
* Fix property type
* Make BroadcastTenancyBootstrapper a singleton in tests
* Fix code style (php-cs-fixer)
* Bind the original broadcaster instance on `revert()`
* Instead of just forgetting the old broadcaster instance, bind the new one
* Add BroadcastTenancyBootstrapper tests
* Separate the test
* Fix code style (php-cs-fixer)
* Add bootstrapper test
* Add broadcaster channels test
* Clean up BootstrapperTest
* Fix BroadcastingTest
* Add comments to TenancyBroadcastManager
* Add BroadcastTenancyBootstrapper comments
* Simplify BroadcastManager extension, remove setDriver method
* Add comment
* Fix PHPStan errors
* Fix PHPStan errors
* Remove duplicate import
* Fix test
* Delete `::class` from test name
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* Create databases for newly created tenants in BroadcastingTest
* move spatie/invade to require
---------
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* Add UrlTenancyBootstrapper
* Fix code style (php-cs-fixer)
* Move URL overriding to a separate method, call it in `boot()`
* Test URL root overriding
* Change parameter formatting
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* Fix code style (php-cs-fixer)
* Improve URL bootstrapper test
* Move `$scheme` and `$hostname` to the closure
* Update code example comment
* Hardcode values instead of referencing variables
* Delete extra line
---------
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* Bump dependencies for Laravel 10
* Update GitHub Actions for Laravel 10
* ci: do not test L10 using PHP 7.3
* drop < L9 support
* use `dispatch_sync` instead of `dispatch_now`
* migrate phpunit configuration
* Update ci.yml
* drop laravel < 9 support
* misc L10 fixes, new docker image
* specify odbc version
* wip
* properly list php versions as strings
* minor changes
* Add `getValue($queryGrammar)` to raw query
* Clean up `isVersion8` code
* rewrite hasFailed assertion
* phpunit schema update
* Upgrade `doctrine/dbal`
---------
Co-authored-by: Samuel Štancl <samuel@archte.ch>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
Co-authored-by: lukinovec <lukinovec@gmail.com>
* wip
* Fix code style (php-cs-fixer)
* adjust tests
* Update ResourceSyncingPolymorphicTest.php
* Update SyncMaster.php
* correct method name
* Update ResourceSyncingPolymorphicTest.php
* use BelongsToMany return type
* separate pivot model for each approach
* ability to publish migrations
* remove unsed import
* use resource migrations from asset
* anonymous migration for `tenant_resources` table
* rename file
* rename classes
* trait
* add back using statement
* revert to unset change
* use unset approach
* use unset approach
* Assert `tenants` are accessible
* Update ResourceSyncingUsingPolymorphicTest.php
* improve `tenants` assertions
* improve assertions
* remove `getResourceTenantModelName` method and use config
* use `BelongsToMany` for `tenants` method return type
* Fix code style (php-cs-fixer)
* revert type
* use correct key
* test right resources are accessible from the tenant
* Update tests/ResourceSyncingUsingPolymorphicTest.php
---------
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel@archte.ch>
* Add and test Migrate command's skip-failing option
* Improve naming
* Move migration event dispatching inside try block
* Change test name
* Fix skip-failing test
* Use QueryException instead of Exception
* Correct TenantDatabaseDoesNotExistException import
* Correct test
* Check for the the testing env in DB bootstrapper
* Correct the Migrate command
* Fix code style (php-cs-fixer)
* add docs todo
* Add QueryException to the Migrat command try/catch
* Return status codes in Migrate
* Fix code style (php-cs-fixer)
* Add test for not stopping tenants:migrate after the first failure
* Update Migrate command
* Fix code style (php-cs-fixer)
* Fix code style (php-cs-fixer)
* Use `getTenants()`
* Use withtenantDatabases where needed
* Add withTenantDatabases to test
---------
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
* Replace MailManager singleton with an instance of a custom mail manager which always resolves the mailers instead of getting the cached ones
* Fix code style (php-cs-fixer)
* Add MailTenancyBootstrapper
* Add MailTenancyBootstrapper to tenancy.bootstrappers config (commented out)
* Fix code style (php-cs-fixer)
* Make credentials map a public static property
* Always resolve only the mailers specified in the mailersToNotCache public static property
* Fix typo in comment
* Update TenancyServiceProvider comment
* add todo
* Add comments to TenancyMailManager, rename property
* Remove the configKey array check
* Simplify bootstrap method
* Change $credentialsMap so that config keys are the keys, and the tenant property names are the values
* Rename $mailersToAlwaysResolve to $tenantMailers
* Update comment
* Update comment
* Rename variable in TenancyServiceProvider comment
* Scaffold tests
* Update comments after review
* Uncomment MailTenancyBootstrapper in config
* Use array_key_exists instead of null check
* Split config logic into methods
* Update mapping credentials
* Add tests for the added logic
* Fix code style (php-cs-fixer)
* Delete default 'smtp' mailer in $tenantMailers
* Add separate method to pick the appropriate mail credentials map preset
* Specify test name
* Move mail bootstrapper tests to BootstrapperTest
* Depend less on the default mailer by adding a static `$mailer` property
* Use static property for map presets
* Comment out MailTenancyBootstrapper from config
* Add return types to MailTenancyBootstrapper methods
* Update test name
* Move MailManager extension to MailTenancyBootstrapper
* Fix code style (php-cs-fixer)
* Update config reverting test
* Use `invade()` instead of ReflectionClass
* Fix constructor parameter formatting
* Delete TenancyMailManager, update tests
* Add return type
* Update comment
* Update MailTest
* Delete `group('mailer')`
* Delete bindNewMailManagerInstance()
* Delete remaining `group('mailer')`
* Fix comment
* Fix comment
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>