Services
in package
External services helper.
Other packages or custom modules can register concrete implementations of the interfaces defined in the Sprout\Services namespace.
Table of Contents
Constants
- SERVICES : mixed = ['admin-auth' => \Sprout\Services\AdminAuthInte...
Properties
- $configs : array<string|int, mixed>
- Configs.
- $instances : array<string|int, mixed>
- Service instances.
- $locked : bool
- Lock the service registry.
- $services : array<string|int, mixed>
- Registered services.
Methods
- config() : null|array<string|int, mixed>
- The config for a given service.
- get() : object|null
- Get a service instance.
- getRemoteAuth() : RemoteAuthInterface|null
- Get the remote auth service.
- getTrace() : TraceInterface|null
- Get the tracing service.
- getUserAuth() : UserAuthInterface
- Get the user auth service.
- getUserPermissions() : UserPermsInterface
- Get the user permissions helper.
- key() : null|string
- Get the config key for a service.
- lock() : void
- Arm the 'locked' flag to prevent further service registrations.
- register() : void
- Register a service.
Constants
SERVICES
public
mixed
SERVICES
= ['admin-auth' => \Sprout\Services\AdminAuthInterface::class, 'user-auth' => \Sprout\Services\UserAuthInterface::class, 'user-perms' => \Sprout\Services\UserPermsInterface::class, 'remote' => \Sprout\Services\RemoteAuthInterface::class, 'trace' => \Sprout\Services\TraceInterface::class]
Properties
$configs
Configs.
private
static array<string|int, mixed>
$configs
= []
[interface => config]
$instances
Service instances.
private
static array<string|int, mixed>
$instances
= []
[interface => object]
$locked
Lock the service registry.
private
static bool
$locked
= false
This is to prevent rogue code adding services after the fact.
$services
Registered services.
private
static array<string|int, mixed>
$services
= []
[interface => class]
Methods
config()
The config for a given service.
public
static config(string $interface) : null|array<string|int, mixed>
These can be specified inline when registering the service.
Or, they can be specified in the 'service' config file. Inline configurations have priority.
Parameters
- $interface : string
Tags
Return values
null|array<string|int, mixed>get()
Get a service instance.
public
static get(string $interface) : object|null
Parameters
- $interface : string
Return values
object|nullgetRemoteAuth()
Get the remote auth service.
public
static getRemoteAuth() : RemoteAuthInterface|null
This has no default implementation.
Return values
RemoteAuthInterface|nullgetTrace()
Get the tracing service.
public
static getTrace() : TraceInterface|null
This has no default implementation.
Return values
TraceInterface|nullgetUserAuth()
Get the user auth service.
public
static getUserAuth() : UserAuthInterface
Sprout provides a default implementation. It just says no most of the time.
Return values
UserAuthInterfacegetUserPermissions()
Get the user permissions helper.
public
static getUserPermissions() : UserPermsInterface
Sprout provides a default implementation.
Return values
UserPermsInterfacekey()
Get the config key for a service.
public
static key(string $interface) : null|string
Parameters
- $interface : string
Return values
null|stringlock()
Arm the 'locked' flag to prevent further service registrations.
public
static lock() : void
register()
Register a service.
public
static register(string $class_name[, array<string|int, mixed> $config = null ]) : void
Parameters
- $class_name : string
- $config : array<string|int, mixed> = null