Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/27/2024 09:11:27 PM (15 months ago)
Author:
espellcaste
Message:

Include the V2 of the BP REST API in BuddyPress core.

We are officially deprecating the V1 of the BP REST API. And bundling the new, default, V2 of the BP REST API inside BuddyPress core. Previously, the V1 was developed as a plugin in a separate repo (https://github.com/buddypress/BP-REST).

  • One of the main differences between the V1 and V2 is how objects are returned. Single items are no longer returned as an array;
  • We have a new BP_Test_REST_Controller_Testcase for testing the new API endpoints;
  • We changed the names of our controllers to follow our autoloader rules;
  • Removed the BP-REST plugin from wp-env and from our release script;
  • And we added notices for the deprecated V1 API (endpoints and files).

Props imath & I. ;)

Fixes #8200
See #9145
Closes https://github.com/buddypress/buddypress/pull/337

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/assets/bp-rest-api-controllers.php

    r13414 r14026  
    1 <?php
    2 /**
    3  * BP REST Controllers' mocks
    4  */
    5 
    6 class BP_REST_Mock_Class {
    7     public function __construct() {}
    8 
    9     public function register_routes( $controller = '' ) {
    10         array_push( buddypress()->unit_test_rest->controllers, $controller );
    11     }
    12 }
    13 
    14 /**
    15  * BP Member Cover Image REST Controller's mock.
    16  */
    17 #[AllowDynamicProperties]
    18 class BP_REST_Attachments_Member_Cover_Endpoint extends BP_REST_Mock_Class {
    19     public function __construct() {
    20         $this->namespace = bp_rest_namespace() . '/' . bp_rest_version();
    21         $this->rest_base = 'members';
    22     }
    23 
    24     public function register_routes( $controller = '' ) {
    25         parent::register_routes( 'BP_REST_Attachments_Member_Cover_Endpoint' );
    26     }
    27 }
    28 
    29 /**
    30  * BP Member Avatar REST Controller's mock.
    31  */
    32 #[AllowDynamicProperties]
    33 class BP_REST_Attachments_Member_Avatar_Endpoint extends BP_REST_Mock_Class {
    34     public function __construct() {
    35         $this->namespace = bp_rest_namespace() . '/' . bp_rest_version();
    36         $this->rest_base = 'members';
    37     }
    38 
    39     public function register_routes( $controller = '' ) {
    40         parent::register_routes( 'BP_REST_Attachments_Member_Avatar_Endpoint' );
    41     }
    42 }
    43 
    44 /**
    45  * BP Components REST Controller's mock.
    46  */
    47 #[AllowDynamicProperties]
    48 class BP_REST_Components_Endpoint extends BP_REST_Mock_Class {
    49     public function __construct() {
    50         $this->namespace = bp_rest_namespace() . '/' . bp_rest_version();
    51         $this->rest_base = 'components';
    52     }
    53 
    54     public function register_routes( $controller = '' ) {
    55         parent::register_routes( 'BP_REST_Components_Endpoint' );
    56     }
    57 }
    58 
    59 /**
    60  * BP Members REST Controller's mock.
    61  */
    62 #[AllowDynamicProperties]
    63 class BP_REST_Members_Endpoint extends BP_REST_Mock_Class {
    64     public function __construct() {
    65         $this->namespace = bp_rest_namespace() . '/' . bp_rest_version();
    66         $this->rest_base = 'members';
    67     }
    68 
    69     public function register_routes( $controller = '' ) {
    70         parent::register_routes( 'BP_REST_Members_Endpoint' );
    71     }
    72 }
Note: See TracChangeset for help on using the changeset viewer.