Automattic\WooCommerce\Internal\DependencyManagement
ExtendedContainer::add() public WC 1.0
Register a class in the container.
{} Это метод класса: ExtendedContainer{}
Хуков нет.
Возвращает
DefinitionInterface. The generated definition for the container.
Использование
$ExtendedContainer = new ExtendedContainer(); $ExtendedContainer->add( $class_name, $concrete, $shared ) : DefinitionInterface;
- $class_name(строка) (обязательный)
- Class name.
- $concrete(смешанный)
- How to resolve the class with get: a factory callback, a concrete instance, another class name, or null to just create an instance of the class.
По умолчанию: null - $shared(true/false)
- Whether the resolution should be performed only once and cached.
По умолчанию: null
Код ExtendedContainer::add() ExtendedContainer::add WC 4.9.0
public function add( string $class_name, $concrete = null, bool $shared = null ) : DefinitionInterface {
if ( ! $this->is_class_allowed( $class_name ) ) {
throw new ContainerException( "You cannot add '$class_name', only classes in the {$this->woocommerce_namespace} namespace are allowed." );
}
$concrete_class = $this->get_class_from_concrete( $concrete );
if ( isset( $concrete_class ) && ! $this->is_class_allowed( $concrete_class ) ) {
throw new ContainerException( "You cannot add concrete '$concrete_class', only classes in the {$this->woocommerce_namespace} namespace are allowed." );
}
// We want to use a definition class that does not support constructor injection to avoid accidental usage.
if ( ! $concrete instanceof DefinitionInterface ) {
$concrete = new Definition( $class_name, $concrete );
}
return parent::add( $class_name, $concrete, $shared );
}