WC_CLI_REST_Command::__construct()
Sets up REST Command.
Метод класса: WC_CLI_REST_Command{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
$WC_CLI_REST_Command = new WC_CLI_REST_Command(); $WC_CLI_REST_Command->__construct( $name, $route, $schema );
- $name(строка) (обязательный)
- Name of endpoint object (comes from schema).
- $route(строка) (обязательный)
- Path to route of this endpoint.
- $schema(массив) (обязательный)
- Schema object.
Код WC_CLI_REST_Command::__construct() WC CLI REST Command:: construct WC 9.6.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]; } } }