Format
extends BaseConfig
in package
Class BaseConfig
Not intended to be used on its own, this class will attempt to automatically populate the child class' properties with values from the environment.
These can be set within the .env file.
Table of Contents
- $formatterOptions : array<string, int>
- -------------------------------------------------------------------------- Formatters Options --------------------------------------------------------------------------
- $formatters : array<string, string>
- -------------------------------------------------------------------------- Formatters --------------------------------------------------------------------------
- $registrars : array<string|int, mixed>
- An optional array of classes that will act as Registrars for rapidly setting config class properties.
- $supportedResponseFormats : array<string|int, string>
- -------------------------------------------------------------------------- Available Response Formats --------------------------------------------------------------------------
- $didDiscovery : bool
- Has module discovery happened yet?
- $moduleConfig : Modules
- The modules configuration.
- __construct() : mixed
- Will attempt to get environment variables with names that match the properties of the child class.
- getFormatter() : FormatterInterface
- A Factory method to return the appropriate formatter for the given mime type.
- getEnvValue() : mixed
- Retrieve an environment-specific configuration setting
- initEnvValue() : mixed
- Initialization an environment-specific configuration setting
- registerProperties() : mixed
- Provides external libraries a simple way to register one or more options into a config file.
Properties
$formatterOptions
-------------------------------------------------------------------------- Formatters Options --------------------------------------------------------------------------
public
array<string, int>
$formatterOptions
= ['application/json' => JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES, 'application/xml' => 0, 'text/xml' => 0]
Additional Options to adjust default formatters behaviour. For each mime type, list the additional options that should be used.
$formatters
-------------------------------------------------------------------------- Formatters --------------------------------------------------------------------------
public
array<string, string>
$formatters
= ['application/json' => 'CodeIgniter\Format\JSONFormatter', 'application/xml' => 'CodeIgniter\Format\XMLFormatter', 'text/xml' => 'CodeIgniter\Format\XMLFormatter']
Lists the class to use to format responses with of a particular type. For each mime type, list the class that should be used. Formatters can be retrieved through the getFormatter() method.
$registrars
An optional array of classes that will act as Registrars for rapidly setting config class properties.
public
static array<string|int, mixed>
$registrars
= []
$supportedResponseFormats
-------------------------------------------------------------------------- Available Response Formats --------------------------------------------------------------------------
public
array<string|int, string>
$supportedResponseFormats
= [
'application/json',
'application/xml',
// machine-readable XML
'text/xml',
]
When you perform content negotiation with the request, these are the available formats that your application supports. This is currently only used with the API\ResponseTrait. A valid Formatter must exist for the specified format.
These formats are only checked when the data passed to the respond() method is an array.
$didDiscovery
Has module discovery happened yet?
protected
static bool
$didDiscovery
= false
$moduleConfig
The modules configuration.
protected
static Modules
$moduleConfig
Methods
__construct()
Will attempt to get environment variables with names that match the properties of the child class.
public
__construct() : mixed
The "shortPrefix" is the lowercase-only config class name.
Return values
mixed —getFormatter()
A Factory method to return the appropriate formatter for the given mime type.
public
getFormatter(string $mime) : FormatterInterface
Parameters
- $mime : string
Tags
Return values
FormatterInterface —getEnvValue()
Retrieve an environment-specific configuration setting
protected
getEnvValue(string $property, string $prefix, string $shortPrefix) : mixed
Parameters
- $property : string
- $prefix : string
- $shortPrefix : string
Return values
mixed —initEnvValue()
Initialization an environment-specific configuration setting
protected
initEnvValue(mixed &$property, string $name, string $prefix, string $shortPrefix) : mixed
Parameters
- $property : mixed
- $name : string
- $prefix : string
- $shortPrefix : string
Return values
mixed —registerProperties()
Provides external libraries a simple way to register one or more options into a config file.
protected
registerProperties() : mixed