Skip to:
Content

BuddyPress.org

Changeset 12607


Ignore:
Timestamp:
03/31/2020 11:33:35 AM (7 years ago)
Author:
imath
Message:

Prepare the inclusion of the BP REST API remaining endpoints

6.0.0 is introducing 6 new BP REST API endpoints :

  • Blogs, Blog avatar,
  • Friends,
  • Group Cover image,
  • Member Cover Image and User Signups

We're also reorganizing files, making sure they are located to their belonging endpoints. As a result, 2 files are now deprecated:

  • bp-core/classes/class-bp-rest-attachments-group-avatar-endpoint.php (moved into bp-groups/classes)
  • bp-core/classes/class-bp-rest-attachments-member-avatar-endpoint.php (moved into bp-members/classes)

Props espellcaste, boonebgorges & I ;)

Fixes #7156

Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-blogs/classes/class-bp-blogs-component.php

    r12587 r12607  
    357357                parent::setup_cache_groups();
    358358        }
     359
     360        /**
     361         * Init the BP REST API.
     362         *
     363         * @since 6.0.0
     364         *
     365         * @param array $controllers Optional. See BP_Component::rest_api_init() for
     366         *                           description.
     367         */
     368        public function rest_api_init( $controllers = array() ) {
     369                if ( is_multisite() ) {
     370                        $controllers = array(
     371                                'BP_REST_Blogs_Endpoint',
     372                        );
     373
     374                        // Support to Blog Avatar.
     375                        if ( bp_is_active( 'blogs', 'site-icon' ) ) {
     376                                $controllers[] = 'BP_REST_Attachments_Blog_Avatar_Endpoint';
     377                        }
     378                }
     379
     380                parent::rest_api_init( $controllers );
     381        }
    359382}
  • trunk/src/bp-friends/classes/class-bp-friends-component.php

    r12589 r12607  
    326326                parent::setup_cache_groups();
    327327        }
     328
     329        /**
     330         * Init the BP REST API.
     331         *
     332         * @since 6.0.0
     333         *
     334         * @param array $controllers Optional. See BP_Component::rest_api_init() for
     335         *                           description.
     336         */
     337        public function rest_api_init( $controllers = array() ) {
     338                parent::rest_api_init( array( 'BP_REST_Friends_Endpoint' ) );
     339        }
    328340}
  • trunk/src/bp-groups/classes/class-bp-groups-component.php

    r12590 r12607  
    937937         *
    938938         * @since 5.0.0
     939         * @since 6.0.0 Adds the Group Cover REST endpoint.
    939940         *
    940941         * @param array $controllers Optional. See BP_Component::rest_api_init() for
    … …  
    942943         */
    943944        public function rest_api_init( $controllers = array() ) {
    944                 parent::rest_api_init( array(
     945                $controllers = array(
    945946                        'BP_REST_Groups_Endpoint',
    946947                        'BP_REST_Group_Membership_Endpoint',
    … …  
    948949                        'BP_REST_Group_Membership_Request_Endpoint',
    949950                        'BP_REST_Attachments_Group_Avatar_Endpoint',
    950                 ) );
     951                );
     952
     953                // Support to Group Cover.
     954                if ( bp_is_active( 'groups', 'cover_image' ) ) {
     955                        $controllers[] = 'BP_REST_Attachments_Group_Cover_Endpoint';
     956                }
     957
     958                parent::rest_api_init( $controllers );
    951959        }
    952960
  • trunk/src/bp-members/classes/class-bp-members-component.php

    r12579 r12607  
    655655         *
    656656         * @since 5.0.0
     657         * @since 6.0.0 Adds the Member Cover and Signup REST endpoints.
    657658         *
    658659         * @param array $controllers Optional. See BP_Component::rest_api_init() for
    … …  
    660661         */
    661662        public function rest_api_init( $controllers = array() ) {
    662                 parent::rest_api_init( array(
     663                $controllers = array(
    663664                        /**
    664665                         * As the Members component is always loaded,
    … …  
    668669                        'BP_REST_Members_Endpoint',
    669670                        'BP_REST_Attachments_Member_Avatar_Endpoint',
    670                 ) );
     671                );
     672
     673                if ( bp_is_active( 'members', 'cover_image' ) ) {
     674                        $controllers[] = 'BP_REST_Attachments_Member_Cover_Endpoint';
     675                }
     676
     677                if ( bp_get_signup_allowed() ) {
     678                        $controllers[] = 'BP_REST_Signup_Endpoint';
     679                }
     680
     681                parent::rest_api_init( $controllers );
    671682        }
    672683
  • trunk/src/class-buddypress.php

    r12578 r12607  
    551551                        'BP_REST_Activity_Endpoint' => 'activity',
    552552
    553                         'BP_Admin'                                   => 'core',
    554                         'BP_Attachment_Avatar'                       => 'core',
    555                         'BP_Attachment_Cover_Image'                  => 'core',
    556                         'BP_Attachment'                              => 'core',
    557                         'BP_Button'                                  => 'core',
    558                         'BP_Block'                                   => 'core',
    559                         'BP_Component'                               => 'core',
    560                         'BP_Customizer_Control_Range'                => 'core',
    561                         'BP_Date_Query'                              => 'core',
    562                         'BP_Email_Delivery'                          => 'core',
    563                         'BP_Email_Address'                           => 'core',
    564                         'BP_Email_Recipient'                         => 'core',
    565                         'BP_Email_Sender'                            => 'core',
    566                         'BP_Email_Participant'                       => 'core',
    567                         'BP_Email'                                   => 'core',
    568                         'BP_Embed'                                   => 'core',
    569                         'BP_Media_Extractor'                         => 'core',
    570                         'BP_Members_Suggestions'                     => 'core',
    571                         'BP_PHPMailer'                               => 'core',
    572                         'BP_Recursive_Query'                         => 'core',
    573                         'BP_Suggestions'                             => 'core',
    574                         'BP_Theme_Compat'                            => 'core',
    575                         'BP_User_Query'                              => 'core',
    576                         'BP_Walker_Category_Checklist'               => 'core',
    577                         'BP_Walker_Nav_Menu_Checklist'               => 'core',
    578                         'BP_Walker_Nav_Menu'                         => 'core',
    579                         'BP_Invitation_Manager'                      => 'core',
    580                         'BP_Invitation'                              => 'core',
    581                         'BP_REST_Components_Endpoint'                => 'core',
    582                         'BP_REST_Attachments'                        => 'core',
    583                         'BP_REST_Attachments_Member_Avatar_Endpoint' => 'core',
    584                         'BP_REST_Attachments_Group_Avatar_Endpoint'  => 'core',
    585 
    586                         'BP_Core_Friends_Widget' => 'friends',
     553                        'BP_REST_Blogs_Endpoint'                   => 'blogs',
     554                        'BP_REST_Attachments_Blog_Avatar_Endpoint' => 'blogs',
     555
     556                        'BP_Admin'                     => 'core',
     557                        'BP_Attachment_Avatar'         => 'core',
     558                        'BP_Attachment_Cover_Image'    => 'core',
     559                        'BP_Attachment'                => 'core',
     560                        'BP_Button'                    => 'core',
     561                        'BP_Block'                     => 'core',
     562                        'BP_Component'                 => 'core',
     563                        'BP_Customizer_Control_Range'  => 'core',
     564                        'BP_Date_Query'                => 'core',
     565                        'BP_Email_Delivery'            => 'core',
     566                        'BP_Email_Address'             => 'core',
     567                        'BP_Email_Recipient'           => 'core',
     568                        'BP_Email_Sender'              => 'core',
     569                        'BP_Email_Participant'         => 'core',
     570                        'BP_Email'                     => 'core',
     571                        'BP_Embed'                     => 'core',
     572                        'BP_Media_Extractor'           => 'core',
     573                        'BP_Members_Suggestions'       => 'core',
     574                        'BP_PHPMailer'                 => 'core',
     575                        'BP_Recursive_Query'           => 'core',
     576                        'BP_Suggestions'               => 'core',
     577                        'BP_Theme_Compat'              => 'core',
     578                        'BP_User_Query'                => 'core',
     579                        'BP_Walker_Category_Checklist' => 'core',
     580                        'BP_Walker_Nav_Menu_Checklist' => 'core',
     581                        'BP_Walker_Nav_Menu'           => 'core',
     582                        'BP_Invitation_Manager'        => 'core',
     583                        'BP_Invitation'                => 'core',
     584                        'BP_REST_Components_Endpoint'  => 'core',
     585                        'BP_REST_Attachments'          => 'core',
     586
     587                        'BP_Core_Friends_Widget'   => 'friends',
     588                        'BP_REST_Friends_Endpoint' => 'friends',
    587589
    588590                        'BP_Group_Extension'                        => 'groups',
    … …  
    592594                        'BP_REST_Group_Invites_Endpoint'            => 'groups',
    593595                        'BP_REST_Group_Membership_Request_Endpoint' => 'groups',
    594 
    595                         'BP_Core_Members_Template'       => 'members',
    596                         'BP_Core_Members_Widget'         => 'members',
    597                         'BP_Core_Recently_Active_Widget' => 'members',
    598                         'BP_Core_Whos_Online_Widget'     => 'members',
    599                         'BP_Registration_Theme_Compat'   => 'members',
    600                         'BP_Signup'                      => 'members',
    601                         'BP_REST_Members_Endpoint'       => 'members',
     596                        'BP_REST_Attachments_Group_Avatar_Endpoint' => 'groups',
     597                        'BP_REST_Attachments_Group_Cover_Endpoint'  => 'groups',
     598
     599                        'BP_Core_Members_Template'                   => 'members',
     600                        'BP_Core_Members_Widget'                     => 'members',
     601                        'BP_Core_Recently_Active_Widget'             => 'members',
     602                        'BP_Core_Whos_Online_Widget'                 => 'members',
     603                        'BP_Registration_Theme_Compat'               => 'members',
     604                        'BP_Signup'                                  => 'members',
     605                        'BP_REST_Members_Endpoint'                   => 'members',
     606                        'BP_REST_Attachments_Member_Avatar_Endpoint' => 'members',
     607                        'BP_REST_Attachments_Member_Cover_Endpoint'  => 'members',
     608                        'BP_REST_Signup_Endpoint'                    => 'members',
    602609
    603610                        'BP_REST_Messages_Endpoint' => 'messages',
  • trunk/tests/phpunit/assets/bp-rest-api-controllers.php

    r12485 r12607  
    99        public function register_routes( $controller = '' ) {
    1010                array_push( buddypress()->unit_test_rest->controllers, $controller );
     11        }
     12}
     13
     14/**
     15 * BP Member Cover Image REST Controller's mock.
     16 */
     17class BP_REST_Attachments_Member_Cover_Endpoint extends BP_REST_Mock_Class {
     18        public function __construct() {
     19                $this->namespace = bp_rest_namespace() . '/' . bp_rest_version();
     20                $this->rest_base = 'members';
     21        }
     22
     23        public function register_routes( $controller = '' ) {
     24                parent::register_routes( 'BP_REST_Attachments_Member_Cover_Endpoint' );
    1125        }
    1226}
  • trunk/tests/phpunit/testcases/core/class-bp-component.php

    r12559 r12607  
    3434                        'BP_REST_Members_Endpoint',
    3535                        'BP_REST_Attachments_Member_Avatar_Endpoint',
     36                        'BP_REST_Attachments_Member_Cover_Endpoint',
    3637                ) );
    3738        }
    … …  
    5051                        'BP_REST_Components_Endpoint',
    5152                        'BP_REST_Attachments_Member_Avatar_Endpoint',
     53                        'BP_REST_Attachments_Member_Cover_Endpoint',
    5254                ) );
    5355        }
    … …  
    6769                        'BP_REST_Members_Endpoint',
    6870                        'BP_REST_Attachments_Member_Avatar_Endpoint',
     71                        'BP_REST_Attachments_Member_Cover_Endpoint',
    6972                ) );
    7073        }
Note: See TracChangeset for help on using the changeset viewer.