Yoast\WP\SEO

Loader::get_class()protectedYoast 1.0

Gets a class from the container.

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

Хуков нет.

Возвращает

Объект|null. The class or, in production environments, null if it does not exist.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_class( $class );
$class(строка) (обязательный)
The class name.

Код Loader::get_class() Yoast 19.10

protected function get_class( $class ) {
	try {
		return $this->container->get( $class );
	} catch ( Throwable $e ) {
		// In production environments do not fatal if the class could not be constructed but log and fail gracefully.
		if ( YOAST_ENVIRONMENT === 'production' ) {
			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
				// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
				error_log( $e->getMessage() );
			}
			return null;
		}
		throw $e;
	} catch ( Exception $e ) { // Also catch Exception for PHP 5.6 compatibility.
		// In production environments do not fatal if the class could not be constructed but log and fail gracefully.
		if ( YOAST_ENVIRONMENT === 'production' ) {
			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
				// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
				error_log( $e->getMessage() );
			}
			return null;
		}
		throw $e;
	}
}