WordPress at Your Fingertips
function is not described

WC_CLI_REST_Command::__construct() public WC 1.0

Sets up REST Command.

{} It's a method of the class: WC_CLI_REST_Command{}

No Hooks.

Return

null. Nothing.

Usage

$WC_CLI_REST_Command = new WC_CLI_REST_Command();
$WC_CLI_REST_Command->__construct( $name, $route, $schema );
$name(string) (required)
Name of endpoint object (comes from schema).
$route(string) (required)
Path to route of this endpoint.
$schema(array) (required)
Schema object.

Code of WC_CLI_REST_Command::__construct() WC 5.9.0

public function __construct( $name, $route, $schema ) {
	$this->name = $name;

	preg_match_all( '#\([^\)]+\)#', $route, $matches );
	$first_match  = $matches[0];
	$resource_id  = ! empty( $matches[0] ) ? array_pop( $matches[0] ) : null;
	$this->route  = rtrim( $route );
	$this->schema = $schema;

	$this->resource_identifier = $resource_id;
	if ( in_array( $name, $this->routes_with_parent_id, true ) ) {
		$is_singular = substr( $this->route, - strlen( $resource_id ) ) === $resource_id;
		if ( ! $is_singular ) {
			$this->resource_identifier = $first_match[0];
		}
	}
}