ServiceProvider
Registers the locale resolver service.
Locale options are read from locale config and control the default locale, session key, resolution mode, and allowed locale list. The service is shared because locale state can be reused by translation, view, and controller logic during the same request.
- Full name:
\PhalconKit\Provider\Locale\ServiceProvider - Parent class:
\PhalconKit\Provider\AbstractServiceProvider
Properties
defaultOptions
Default locale options used when config does not provide values.
public array{default: string, sessionKey: string, mode: string, allowed: array<int,string>} $defaultOptions
serviceName
Stable DI service name managed by this provider.
protected string $serviceName
This value is part of the provider contract because controllers, tasks, other injectables, and replacement providers resolve services by name. Concrete providers must set it to a non-empty value.
Methods
register
Register the shared locale service.
public register(\PhalconKit\Di\DiInterface $di): void
Runtime options can override config when resolving the service manually, mainly for tests or custom bootstraps.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$di | \PhalconKit\Di\DiInterface |
Inherited methods
__construct
Stores the DI container and prepares the provider for registration.
public __construct(\PhalconKit\Di\DiInterface $di): mixed
The constructor intentionally requires PhalconKit\Di\DiInterface so providers can rely on typed service helpers during configuration and registration.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$di | \PhalconKit\Di\DiInterface |
Throws:
When a concrete provider does not define a non-empty service name. - LogicException
getName
Returns the DI service name managed by this provider.
public getName(): string
boot
Optional post-registration hook.
public boot(): void
The base implementation is intentionally empty. Custom bootstraps or application code may call this method for provider-specific startup work after all services have been registered.
configure
Optional provider-local configuration hook.
public configure(): void
This runs during construction after DI has been stored and before register() is called. Use it to normalize provider options or prepare lightweight state; service creation belongs in register().