abstract class Config (View source)

Constants

UNINHERITED

source options bitmask value - only get configuration set for this specific class, not any of it's parents.

EXCLUDE_EXTRA_SOURCES

NO_DELTAS

Disable all modifications to the config

Methods

inst()

Get the current active Config instance.

modify()

Make this config available to be modified

nest()

Make the newly active {@link Config} be a copy of the current active {@link Config} instance.

unnest()

Change the active Config back to the Config instance the current active Config object was copied from.

static Config_ForClass
forClass(string $class)

Get an accessor that returns results by class by default.

static mixed
withConfig(callable $callback)

Perform the given operation in an isolated config state.

Details

static ConfigCollectionInterface inst()

Get the current active Config instance.

In general use you will use this method to obtain the current Config instance. It assumes the config instance has already been set.

static MutableConfigCollectionInterface modify()

Make this config available to be modified

static ConfigCollectionInterface nest()

Make the newly active {@link Config} be a copy of the current active {@link Config} instance.

You can then make changes to the configuration by calling update and remove on the new value returned by {@link Config::inst()}, and then discard those changes later by calling unnest.

Return Value

ConfigCollectionInterface

Active config

static ConfigCollectionInterface unnest()

Change the active Config back to the Config instance the current active Config object was copied from.

static Config_ForClass forClass(string $class)

Get an accessor that returns results by class by default.

Shouldn't be overridden, since there might be many Config_ForClass instances already held in the wild. Each Config_ForClass instance asks the current_instance of Config for the actual result, so override that instead

Parameters

string $class

Return Value

Config_ForClass

static mixed withConfig(callable $callback)

Perform the given operation in an isolated config state.

On return, the config state will be restored, so any modifications are temporary.

Parameters

callable $callback

Callback to run. Will be passed the nested config state as a parameter

Return Value

mixed

Result of callback