ConfigHelper

Type
Class
Namespace
craft\helpers
Inherits
craft\helpers\ConfigHelper
Since
3.0.0

Config helper

View source (opens new window)

# Public Methods

Method Description
durationInSeconds() Normalizes a time duration value into the number of seconds it represents.
localizedValue() Returns a localized config setting value.
sizeInBytes() Normalizes a file size value into the number of bytes it represents.

# durationInSeconds()

Normalizes a time duration value into the number of seconds it represents.

Accepted formats:

View source (opens new window)

Arguments

  • $value (mixed)

Returns

integer (opens new window) – The time duration in seconds

Throws

# localizedValue()

Returns a localized config setting value.

View source (opens new window)

Arguments

  • $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 (opens new window), null (opens new window)) – The site handle the value should be defined for. Defaults to the current site.

Returns

mixed

# sizeInBytes()

Normalizes a file size value into the number of bytes it represents.

Accepted formats;

View source (opens new window)

Arguments

Returns

integer (opens new window), float (opens new window) – The size in bytes