cted abstract function get_api_info();
/**
* Get REST API Path
*
* @since 6.0.0 Migrated to Common from Event Automator
*
* @return array
*/
protected function get_paths() {
$paths = [];
foreach ( $this->documentation_providers as $path => $endpoint ) {
if ( $endpoint !== $this ) {
/** @var Tribe__Documentation__Swagger__Provider_Interface $endpoint */
$documentation = $endpoint->get_documentation();
} else {
$documentation = $this->get_own_documentation();
}
$paths[ $path ] = $documentation;
}
return $paths;
}
/**
* Registers a documentation provider for a path.
*
* @since 6.0.0 Migrated to Common from Event Automator
*
* @param $path
* @param Tribe__Documentation__Swagger__Provider_Interface $endpoint
*/
public function register_documentation_provider( $path, Tribe__Documentation__Swagger__Provider_Interface $endpoint ) {
$this->documentation_providers[ $path ] = $endpoint;
}
/**
* Get REST API Documentation
*
* @since 6.0.0 Migrated to Common from Event Automator
*
* @return array
*/
protected function get_own_documentation() {
return [
'get' => [
'responses' =>[
'200' => [
'description' => __( 'Returns the documentation for TEC REST API in Swagger consumable format.', 'tribe-common' ),
],
],
],
];
}
/**
* Get REST API Definitions
*
* @since 6.0.0 Migrated to Common from Event Automator
*
* @return array
*/
protected function get_definitions() {
$definitions = [];
/** @var Tribe__Documentation__Swagger__Provider_Interface $provider */
foreach ( $this->definition_providers as $type => $provider ) {
$definitions[ $type ] = $provider->get_documentation();
}
return $definitions;
}
/**
* Get REST API Registered Documentation Providers
*
* @since 6.0.0 Migrated to Common from Event Automator
*
* @return Tribe__Documentation__Swagger__Provider_Interface[]
*/
public function get_registered_documentation_providers() {
return $this->documentation_providers;
}
/**
* Registers a documentation provider for a definition.
*
* @since 6.0.0 Migrated to Common from Event Automator
*
* @param string $type
* @param Tribe__Documentation__Swagger__Provider_Interface $provider
*/
public function register_definition_provider( $type, Tribe__Documentation__Swagger__Provider_Interface $provider ) {
$this->definition_providers[ $type ] = $provider;
}
/**
* Get Documentation Provider Interface
*
* @since 6.0.0 Migrated to Common from Event Automator
*
* @return Tribe__Documentation__Swagger__Provider_Interface[]
*/
public function get_registered_definition_providers() {
return $this->definition_providers;
}
/**
* Returns the content of the `args` array that should be used to register the endpoint
* with the `register_rest_route` function.
*
* @since 6.0.0 Migrated to Common from Event Automator
*
* @return array
*/
public function READ_args() {
return [];
}
}