MultipleInstanceManager
abstract class MultipleInstanceManager
Traits
Properties
| protected Repository | $config | The configuration repository instance. |
|
| protected array | $instances | The array of resolved instances. |
|
| protected array | $customCreators | The registered custom instance creators. |
|
| protected string | $driverKey | The key name of the "driver" equivalent configuration option. |
Methods
Get the default instance name.
Set the default instance name.
Get the instance specific configuration.
Get an instance by name.
Attempt to get an instance from the local cache.
Resolve the given instance.
Call a custom instance creator.
Unset the given instances.
Disconnect the given instance and remove from local cache.
Dynamically call the default instance.
Details
in
RebindsCallbacksToSelf at line 18
protected Closure|null
bindCallbackToSelf(Closure $callback)
Bind the provided callback to the class instance.
at line 41
__construct(Application $app)
Create a new manager instance.
at line 50
abstract string
getDefaultInstance()
Get the default instance name.
at line 58
abstract void
setDefaultInstance(string $name)
Set the default instance name.
Boot-only. Implementations typically mutate process-global config; per-request use races across coroutines. Use coroutine Context for request-scoped overrides.
at line 63
abstract array
getInstanceConfig(string $name)
Get the instance specific configuration.
at line 68
mixed
instance(string|null $name = null)
Get an instance by name.
at line 80
protected mixed
get(string $name)
Attempt to get an instance from the local cache.
at line 91
protected mixed
resolve(string $name)
Resolve the given instance.
at line 123
protected mixed
callCustomCreator(array $config)
Call a custom instance creator.
at line 137
MultipleInstanceManager
forgetInstance(array|string|null $name = null)
Unset the given instances.
Boot or tests only. Mutates the singleton's instance cache; concurrent coroutines may already hold a reference to the forgotten instance and next resolution will rebuild.
at line 157
void
purge(string|null $name = null)
Disconnect the given instance and remove from local cache.
Boot or tests only. Mutates the singleton's instance cache; concurrent coroutines may already hold a reference to the instance and next resolution will rebuild.
at line 175
MultipleInstanceManager
extend(string $name, Closure $callback)
Register a custom instance creator Closure.
Boot-only. The callback persists in the singleton's customCreators array for the worker lifetime and applies to every subsequent instance resolution.
at line 198
MultipleInstanceManager
setApplication(Application $app)
Set the application instance used by the manager.
Tests only. Swaps the singleton's application reference; per-request use races across coroutines and breaks every concurrent resolution through this manager.
at line 208
mixed
__call(string $method, array $parameters)
Dynamically call the default instance.