Automattic\WooCommerce\Internal\Admin\BlockTemplates

BlockTemplateLogger::__construct()protectedWC 1.0

Constructor.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->__construct();

Код BlockTemplateLogger::__construct() WC 9.7.1

protected function __construct() {
	$this->logger = wc_get_logger();

	$threshold = get_option( 'woocommerce_block_template_logging_threshold', \WC_Log_Levels::WARNING );
	if ( ! \WC_Log_Levels::is_valid_level( $threshold ) ) {
		$threshold = \WC_Log_Levels::INFO;
	}

	$this->threshold_severity = \WC_Log_Levels::get_level_severity( $threshold );

	add_action(
		'woocommerce_block_template_after_add_block',
		function ( BlockInterface $block ) {
			$is_detached = method_exists( $block->get_parent(), 'is_detached' ) && $block->get_parent()->is_detached();

			$this->log(
				$is_detached
					? $this::BLOCK_ADDED_TO_DETACHED_CONTAINER
					: $this::BLOCK_ADDED,
				$block,
			);
		},
		0,
	);

	add_action(
		'woocommerce_block_template_after_remove_block',
		function ( BlockInterface $block ) {
			$this->log(
				$this::BLOCK_REMOVED,
				$block,
			);
		},
		0,
	);

	add_action(
		'woocommerce_block_template_after_add_hide_condition',
		function ( BlockInterface $block ) {
			$this->log(
				$block->is_detached()
					? $this::HIDE_CONDITION_ADDED_TO_DETACHED_BLOCK
					: $this::HIDE_CONDITION_ADDED,
				$block,
			);
		},
		0
	);

	add_action(
		'woocommerce_block_template_after_remove_hide_condition',
		function ( BlockInterface $block ) {
			$this->log(
				$this::HIDE_CONDITION_REMOVED,
				$block,
			);
		},
		0
	);

	add_action(
		'woocommerce_block_template_after_add_block_error',
		function ( BlockInterface $block, string $action, \Exception $exception ) {
			$this->log(
				$this::ERROR_AFTER_BLOCK_ADDED,
				$block,
				array(
					'action'    => $action,
					'exception' => $exception,
				),
			);
		},
		0,
		3
	);

	add_action(
		'woocommerce_block_template_after_remove_block_error',
		function ( BlockInterface $block, string $action, \Exception $exception ) {
			$this->log(
				$this::ERROR_AFTER_BLOCK_REMOVED,
				$block,
				array(
					'action'    => $action,
					'exception' => $exception,
				),
			);
		},
		0,
		3
	);
}