Skip to content

Commit

Permalink
Update patterns REST controllers namespace to stable (#40252)
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras authored Apr 12, 2022
1 parent cef8695 commit 533d306
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class WP_REST_Block_Pattern_Categories_Controller extends WP_REST_Controller {
* @since 6.0.0
*/
public function __construct() {
$this->namespace = '__experimental';
$this->namespace = 'wp/v2';
$this->rest_base = 'block-patterns/categories';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class WP_REST_Block_Patterns_Controller extends WP_REST_Controller {
* Constructor.
*/
public function __construct() {
$this->namespace = '__experimental';
$this->namespace = 'wp/v2';
$this->rest_base = 'block-patterns/patterns';
}

Expand Down
4 changes: 2 additions & 2 deletions packages/core-data/src/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,14 +456,14 @@ export const __experimentalGetCurrentThemeGlobalStylesVariations = () => async (

export const getBlockPatterns = () => async ( { dispatch } ) => {
const patterns = await apiFetch( {
path: '/__experimental/block-patterns/patterns',
path: '/wp/v2/block-patterns/patterns',
} );
dispatch( { type: 'RECEIVE_BLOCK_PATTERNS', patterns } );
};

export const getBlockPatternCategories = () => async ( { dispatch } ) => {
const categories = await apiFetch( {
path: '/__experimental/block-patterns/categories',
path: '/wp/v2/block-patterns/categories',
} );
dispatch( { type: 'RECEIVE_BLOCK_PATTERN_CATEGORIES', categories } );
};
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static function wpTearDownAfterClass() {
public function test_register_routes() {
$routes = rest_get_server()->get_routes();
$this->assertArrayHasKey(
'/__experimental/block-patterns/categories',
'/wp/v2/block-patterns/categories',
$routes,
'The categories route does not exist'
);
Expand All @@ -61,7 +61,7 @@ public function test_get_items() {
$expected_names = array( 'test', 'query' );
$expected_fields = array( 'name', 'label' );

$request = new WP_REST_Request( 'GET', '/__experimental/block-patterns/categories' );
$request = new WP_REST_Request( 'GET', '/wp/v2/block-patterns/categories' );
$request['_fields'] = 'name,label';
$response = rest_get_server()->dispatch( $request );
$data = $response->get_data();
Expand Down
4 changes: 2 additions & 2 deletions phpunit/class-wp-rest-block-patterns-controller-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static function wpTearDownAfterClass() {
public function test_register_routes() {
$routes = rest_get_server()->get_routes();
$this->assertArrayHasKey(
'/__experimental/block-patterns/patterns',
'/wp/v2/block-patterns/patterns',
$routes,
'The patterns route does not exist'
);
Expand All @@ -77,7 +77,7 @@ public function test_get_items() {
$expected_names = array( 'test/one', 'test/two' );
$expected_fields = array( 'name', 'content' );

$request = new WP_REST_Request( 'GET', '/__experimental/block-patterns/patterns' );
$request = new WP_REST_Request( 'GET', '/wp/v2/block-patterns/patterns' );
$request['_fields'] = 'name,content';
$response = rest_get_server()->dispatch( $request );
$data = $response->get_data();
Expand Down

0 comments on commit 533d306

Please sign in to comment.