WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
класс не описан

AbstractDependencyType() WC 2.5.0

An abstract class for dependency types.

Dependency types are instances of a dependency used by the Dependency Injection Container for storing dependencies to invoke as they are needed.

Хуков нет.

Возвращает

Null. Ничего.

Использование

$AbstractDependencyType = new AbstractDependencyType();
// use class methods

Методы

  1. __construct( $callable_or_value )
  2. get( Container $container )
  3. resolve_value( Container $container )

Список изменений

С версии 2.5.0 Введена.

Код AbstractDependencyType: woocommerce/packages/woocommerce-blocks/src/Registry/AbstractDependencyType.php WC 4.3.2

<?php
abstract class AbstractDependencyType {

	/**
	 * Holds a callable or value provided for this type.
	 *
	 * @var mixed
	 */
	private $callable_or_value;

	/**
	 * Constructor
	 *
	 * @param mixed $callable_or_value  A callable or value for the dependency
	 *                                  type instance.
	 */
	public function __construct( $callable_or_value ) {
		$this->callable_or_value = $callable_or_value;
	}

	/**
	 * Resolver for the internal dependency value.
	 *
	 * @param Container $container  The Dependency Injection Container.
	 *
	 * @return mixed
	 */
	protected function resolve_value( Container $container ) {
		$callback = $this->callable_or_value;
		return \method_exists( $callback, '__invoke' )
			? $callback( $container )
			: $callback;
	}

	/**
	 * Retrieves the value stored internally for this DependencyType
	 *
	 * @param Container $container  The Dependency Injection Container.
	 *
	 * @return void
	 */
	abstract public function get( Container $container );
}