Caldera_Forms_API_Load

Loads the Caldera Forms REST API.

Defined (1)

The class is defined in the following location(s).

/classes/api/load.php  
  1. class Caldera_Forms_API_Load { 
  2.  
  3. /** 
  4. * Array of route objects for this collection 
  5. * @since 1.4.4 
  6. * @var array 
  7. */ 
  8. protected $routes; 
  9.  
  10. /** 
  11. * Namespace for this route collection 
  12. * @since 1.4.4 
  13. * @var string 
  14. */ 
  15. protected $namespace; 
  16.  
  17. /** 
  18. * Caldera_Forms_API_Load constructor. 
  19. * @since 1.4.4 
  20. * @param string $namespace Namespace for this route collection 
  21. */ 
  22. public function __construct( $namespace ) { 
  23. $this->namespace = $namespace; 
  24. $this->routes = array(); 
  25.  
  26.  
  27. /** 
  28. * Add a route to this collection 
  29. * @since 1.4.4 
  30. * @param Caldera_Forms_API_Route $route 
  31. */ 
  32. public function add_route( Caldera_Forms_API_Route $route ) { 
  33. $this->routes[] = $route; 
  34.  
  35. /** 
  36. * Initialize routes for this namespace 
  37. * @since 1.4.4 
  38. * @return bool True if loading happened, false if not 
  39. */ 
  40. public function init_routes() { 
  41. if( ! empty( $this->routes ) && ! did_action( "caldera_forms_rest_api_init_$this->namespace" ) ) { 
  42. /** @var Caldera_Forms_API_Route $route */ 
  43. foreach ( $this->routes as $route ) { 
  44. $route->add_routes( $this->namespace ); 
  45.  
  46. /** 
  47. * Runs after Caldera Forms REST API is loaded 
  48. * Dynamic part of hook is the namespace, so may run for each version 
  49. * @since 1.4.4 
  50. * @param array $routes Route objects that were added. 
  51. */ 
  52. do_action( "caldera_forms_rest_api_init_$this->namespace", $this->routes ); 
  53.  
  54. return true; 
  55.  
  56.  
  57. return false; 
  58.  
  59.