Configuration_Loader

Class Configuration_Loader.


Source

File: src/Common/Configuration/Configuration_Loader.php

class Configuration_Loader {
	/**
	 * @var array<Configuration_Provider_Interface>
	 */
	protected static $providers = [];

	/**
	 * Add a var provider to the list of providers referenced when accessing a variable
	 * from within the Configuration object.
	 *
	 * @since 5.1.3
	 *
	 * @param Configuration_Provider_Interface $provider
	 *
	 * @return $this
	 */
	public function add( Configuration_Provider_Interface $provider ): self {
		if ( is_callable( [ $provider, 'register' ] ) ) {
			$provider->register();
		}
		self::$providers[] = $provider;

		return $this;
	}

	/**
	 * Retrieve a list of all Configuration_Provider_Interface providers loaded.
	 *
	 * @since 5.1.3
	 *
	 * @return Configuration_Provider_Interface[]
	 */
	public function all(): array {
		return self::$providers;
	}

	/**
	 * Remove the providers.
	 *
	 * @since 5.1.3
	 *
	 * @return $this
	 */
	public function reset(): self {
		self::$providers = [];

		return $this;
	}
}

Top ↑

Changelog

Changelog
Version Description
5.1.3 Introduced.

Top ↑

Methods

  • add — Add a var provider to the list of providers referenced when accessing a variable from within the Configuration object.
  • all — Retrieve a list of all Configuration_Provider_Interface providers loaded.
  • reset — Remove the providers.