Yoast\WP\Lib\Dependency_Injection

Container_Registry::get()public staticYoast 1.0

Get an instance from a specific container.

Метод класса: Container_Registry{}

Хуков нет.

Возвращает

Объект|null. The service.

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

$result = Container_Registry::get( $name, $id, $invalid_behaviour );
$name(строка) (обязательный)
The name of the container.
$id(строка) (обязательный)
The ID of the service.
$invalid_behaviour(int)
The behaviour when the service could not be found.
По умолчанию: 1

Код Container_Registry::get() Yoast 22.4

public static function get( $name, $id, $invalid_behaviour = 1 ) {
	if ( ! \array_key_exists( $name, self::$containers ) ) {
		if ( $invalid_behaviour === ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE ) {
			throw new ServiceNotFoundException( $id );
		}
		return null;
	}
	return self::$containers[ $name ]->get( $id, $invalid_behaviour );
}