/**
  * Gets all the route information relating to EE models
  * @return array @see get_ee_route_data
  */
 protected function _register_model_routes()
 {
     EE_Registry::instance()->load_helper('Inflector');
     $models_to_register = apply_filters('FHEE__EED_Core_REST_API___register_model_routes', EE_Registry::instance()->non_abstract_db_models);
     //let's not bother having endpoints for extra metas
     unset($models_to_register['Extra_Meta']);
     unset($models_to_register['Extra_Join']);
     $model_routes = array();
     foreach (self::versions_served() as $version => $hidden_endpoint) {
         foreach ($models_to_register as $model_name => $model_classname) {
             //yes we could just register one route for ALL models, but then they wouldn't show up in the index
             $ee_namespace = self::ee_api_namespace . $version;
             $plural_model_route = EEH_Inflector::pluralize_and_lower($model_name);
             $singular_model_route = $plural_model_route . '/(?P<id>\\d+)';
             $model_routes[$ee_namespace][$plural_model_route] = array(array('callback' => array('EventEspresso\\core\\libraries\\rest_api\\controllers\\model\\Read', 'handle_request_get_all'), 'methods' => WP_REST_Server::READABLE, 'hidden_endpoint' => $hidden_endpoint, 'args' => $this->_get_read_query_params($model_name), '_links' => array('self' => rest_url($ee_namespace . $singular_model_route))));
             $model_routes[$ee_namespace][$singular_model_route] = array(array('callback' => array('EventEspresso\\core\\libraries\\rest_api\\controllers\\model\\Read', 'handle_request_get_one'), 'methods' => WP_REST_Server::READABLE, 'hidden_endpoint' => $hidden_endpoint, 'args' => array('include' => array('required' => false, 'default' => '*', 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso')))));
             //@todo: also handle  DELETE for a single item
             $model = EE_Registry::instance()->load_model($model_classname);
             foreach ($model->relation_settings() as $relation_name => $relation_obj) {
                 $related_model_name_endpoint_part = EventEspresso\core\libraries\rest_api\controllers\model\Read::get_related_entity_name($relation_name, $relation_obj);
                 $model_routes[$ee_namespace][$singular_model_route . '/' . $related_model_name_endpoint_part] = array(array('callback' => array('EventEspresso\\core\\libraries\\rest_api\\controllers\\model\\Read', 'handle_request_get_related'), 'methods' => WP_REST_Server::READABLE, 'hidden_endpoint' => $hidden_endpoint, 'args' => $this->_get_read_query_params($relation_name)));
                 //@todo: handle delete related and possibly remove relation (not sure hwo to distinguish)
             }
         }
     }
     return $model_routes;
 }
 /**
  * Gets the route data for EE models in the specified version
  * @param string $version
  * @param boolean $hidden_endpoint
  * @return array
  */
 protected function _get_model_route_data_for_version($version, $hidden_endpoint = false)
 {
     $model_version_info = new \EventEspresso\core\libraries\rest_api\Model_Version_Info($version);
     $models_to_register = apply_filters('FHEE__EED_Core_REST_API___register_model_routes', $model_version_info->models_for_requested_version());
     //let's not bother having endpoints for extra metas
     unset($models_to_register['Extra_Meta']);
     unset($models_to_register['Extra_Join']);
     $model_routes = array();
     foreach ($models_to_register as $model_name => $model_classname) {
         $model = \EE_Registry::instance()->load_model($model_name);
         //yes we could just register one route for ALL models, but then they wouldn't show up in the index
         $plural_model_route = EEH_Inflector::pluralize_and_lower($model_name);
         $singular_model_route = $plural_model_route . '/(?P<id>\\d+)';
         $model_routes[$plural_model_route] = array(array('callback' => array('EventEspresso\\core\\libraries\\rest_api\\controllers\\model\\Read', 'handle_request_get_all'), 'methods' => WP_REST_Server::READABLE, 'hidden_endpoint' => $hidden_endpoint, 'args' => $this->_get_read_query_params($model, $version), '_links' => array('self' => rest_url(EED_Core_Rest_Api::ee_api_namespace . $version . $singular_model_route))));
         $model_routes[$singular_model_route] = array(array('callback' => array('EventEspresso\\core\\libraries\\rest_api\\controllers\\model\\Read', 'handle_request_get_one'), 'methods' => WP_REST_Server::READABLE, 'hidden_endpoint' => $hidden_endpoint, 'args' => $this->_get_response_selection_query_params($model, $version)));
         //@todo: also handle  DELETE for a single item
         foreach ($model->relation_settings() as $relation_name => $relation_obj) {
             $related_model_name_endpoint_part = EventEspresso\core\libraries\rest_api\controllers\model\Read::get_related_entity_name($relation_name, $relation_obj);
             $model_routes[$singular_model_route . '/' . $related_model_name_endpoint_part] = array(array('callback' => array('EventEspresso\\core\\libraries\\rest_api\\controllers\\model\\Read', 'handle_request_get_related'), 'methods' => WP_REST_Server::READABLE, 'hidden_endpoint' => $hidden_endpoint, 'args' => $this->_get_read_query_params($relation_obj->get_other_model(), $version)));
             //@todo: handle delete related and possibly remove relation (not sure hwo to distinguish)
         }
     }
     return $model_routes;
 }