1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-06-21 18:04:06 +00:00

Remove detailed tenancy references from boost resources for better clarity and maintainability

This commit is contained in:
eramitgupta 2026-06-02 12:38:17 +05:30
parent fde2bf0cf4
commit 882eaef8b4
20 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,45 @@
# Context API Reference
Use this when switching between tenant and central contexts.
## Source Files
- `src/Tenancy.php`
- `src/helpers.php`
- `src/Database/Concerns/TenantRun.php`
- `src/Database/Concerns/InitializationHelpers.php`
## Core API
```php
tenancy()->initialize($tenant);
tenancy()->end();
tenancy()->reinitialize();
tenancy()->central(fn () => null);
$tenant->run(fn () => null);
```
## Behavior
- `initialize()` accepts a tenant model, ID, or string key.
- Switching tenants ends the previous context first.
- `run()` restores the previous tenant or central context in `finally`.
- `central()` temporarily ends tenancy and restores prior tenant context.
- `reinitialize()` re-runs bootstrappers for the current tenant.
- `bootstrapFeatures()` is idempotent per feature, but feature bootstrapping is irreversible.
- `find()` resolves tenants through the configured tenant model.
## Helpers
- `tenancy()` returns the tenancy singleton.
- `tenant()` returns current tenant or tenant attribute.
- `central()` executes a callback in central context.
- `globalCache()` resolves central cache.
- `tenant_asset()` returns tenant asset URLs.
- `global_asset()` returns global asset URLs.
## Rules
- Do not manually mutate DB connections, cache prefixes, filesystem roots, queue payloads, sessions, or URL roots.
- Use atomic `run()` and `central()` when context must be restored safely.
- Test context restoration after exceptions.