Automattic\WooCommerce\Api\Infrastructure
ResolverHelpers::create_input
Invoke a factory callable, catching InvalidArgumentException and converting it to a client-visible GraphQL error.
Used to wrap construction of unrolled input types (PaginationParams, ProductFilterInput, etc.) whose constructors may validate their arguments and throw.
Метод класса: ResolverHelpers{}
Хуков нет.
Возвращает
Разное. The return value of the factory.
Использование
$result = ResolverHelpers::create_input( $factory ): mixed;
- $factory(callable) (обязательный)
- A callable that returns the constructed object.
Код ResolverHelpers::create_input() ResolverHelpers::create input WC 11.0.1
public static function create_input( callable $factory ): mixed {
// phpcs:disable WordPress.Security.EscapeOutput.ExceptionNotEscaped -- Not HTML; serialized as JSON.
try {
return $factory();
} catch ( \InvalidArgumentException $e ) {
throw new Error(
$e->getMessage(),
extensions: array( 'code' => 'INVALID_ARGUMENT' )
);
}
// phpcs:enable WordPress.Security.EscapeOutput.ExceptionNotEscaped
}