Automattic\WooCommerce\StoreApi\Schemas

ExtendSchema::get_update_callback()publicWC 1.0

Get callback for a specific endpoint and namespace.

Method of the class: ExtendSchema{}

No Hooks.

Return

callable. The callback registered by the extension.

Usage

$ExtendSchema = new ExtendSchema();
$ExtendSchema->get_update_callback( $namespace );
$namespace(string) (required)
The namespace to get callbacks for.

ExtendSchema::get_update_callback() code WC 9.3.3

public function get_update_callback( $namespace ) {
	if ( ! is_string( $namespace ) ) {
		throw new \Exception( 'You must provide a plugin namespace when extending a Store REST endpoint.' );
	}

	if ( ! array_key_exists( $namespace, $this->callback_methods ) ) {
		throw new \Exception( sprintf( 'There is no such namespace registered: %1$s.', $namespace ) );
	}

	if ( ! array_key_exists( 'callback', $this->callback_methods[ $namespace ] ) || ! is_callable( $this->callback_methods[ $namespace ]['callback'] ) ) {
		throw new \Exception( sprintf( 'There is no valid callback registered for: %1$s.', $namespace ) );
	}

	return $this->callback_methods[ $namespace ]['callback'];
}