tSingleton
MMO\core\classes · 1 symbol · generated 5 Oct 2026
tSingleton
tSingleton.php:16Trait to implement the singleton pattern: exactly one instance of the class exists per request, lazily created on first access and stored in the application's Configuration container, keyed by class name. The instance is built (and configured) from whatever config was Configuration::load-ed for this class name -- see e.g. static::DefaultConfig() on classes extending aModule.
- Namespace
MMO\core\classes
Index
| Instantiate($config) static | (Re)create the shared instance immediately, configured with $config merged into the class's existing config. | |
| IsShared() static | ||
| Shared() static | Get the shared instance, creating (and configuring) it on first call. | |
| Unshare($serialize) static | Remove the shared instance, so the next Shared() call creates a fresh one. |
Methods4
Instantiate($config)
statictSingleton.php:61(Re)create the shared instance immediately, configured with $config merged into the class's existing config.
| $config = [] | array | config values merged in before the instance is constructed |
| returns | static | the newly (re)created shared instance |
IsShared()
statictSingleton.php:49| returns | bool | true if the shared instance has already been created (a call to Shared() would not need to construct a new one) |
Shared()
statictSingleton.php:22Get the shared instance, creating (and configuring) it on first call.
| returns | static |
Unshare($serialize)
statictSingleton.php:35Remove the shared instance, so the next Shared() call creates a fresh one.
- See
serialize) and kept as the class's config, so the next instance created picks up where this one left off; if false, the instance is simply discarded and the next one starts from the class's original config
| $serialize = true | bool | if true (the default) and an instance currently exists, it is serialized first (via |
| returns | bool | true if an instance actually existed and was removed |