Class craft\helpers\ConfigHelper
- Inheritance
- craft\helpers\ConfigHelper
- Available since version
- 3.0
- Source Code
- https://github.com/craftcms/cms/blob/master/src/helpers/ConfigHelper.php
Config helper
Method | Description | Defined By |
---|---|---|
durationInSeconds() |
Normalizes a time duration value into the number of seconds it represents. | craft\helpers\ConfigHelper |
localizedValue() |
Returns a localized config setting value. | craft\helpers\ConfigHelper |
sizeInBytes() |
Normalizes a file size value into the number of bytes it represents. | craft\helpers\ConfigHelper |
Method Details
durationInSeconds()
public static method
#
Normalizes a time duration value into the number of seconds it represents.
Accepted formats:
- integer (the duration in seconds)
- string (a duration interval)
- DateInterval object
- an empty value (represents 0 seconds)
public static integer durationInSeconds ( $value )
$value |
mixed | |
return | integer | The time duration in seconds |
---|---|---|
throws | yii\base\InvalidConfigException | if the duration can't be determined |
localizedValue()
public static method
#
Returns a localized config setting value.
public static mixed localizedValue ( $value, \craft\helpers\string $siteHandle = null )
$value |
mixed | The config setting value. This can be specified in one of the following forms:
A scalar value or null: represents the desired value directly, and will be returned verbatim.
An associative array: represents the desired values across all sites, indexed by site handles.
If a matching site handle isn’t listed, the first value will be returned.
A PHP callable: either an anonymous function or an array representing a class method ([$class or $object, $method] ).
The callable will be passed the site handle if known, and should return the desired config value.
|
$siteHandle |
string, null | The site handle the value should be defined for. Defaults to the current site. |
sizeInBytes()
public static method
#
Normalizes a file size value into the number of bytes it represents.
Accepted formats;
- integer (the size in bytes)
- string (a shorthand byte value ending in
K
(Kilobytes),M
(Megabytes), orG
(Gigabytes))
public static integer, float sizeInBytes ( $value )
$value |
integer, string | The size |
return | integer, float | The size in bytes |
---|