Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| PatternCategoriesController | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
| index | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | namespace NewfoldLabs\WP\Module\Patterns\Api\Controllers; |
| 3 | |
| 4 | use NewfoldLabs\WP\Module\Patterns\Library\Categories; |
| 5 | use NewfoldLabs\WP\Module\Patterns\Api\RemoteRequest; |
| 6 | |
| 7 | /** |
| 8 | * Controller for pattern categories. |
| 9 | */ |
| 10 | class PatternCategoriesController { |
| 11 | |
| 12 | /** |
| 13 | * Return all pattern categories. |
| 14 | */ |
| 15 | public static function index() { |
| 16 | |
| 17 | $data = Categories::get( 'patterns' ); |
| 18 | |
| 19 | if ( \is_wp_error( $data ) ) { |
| 20 | return new \WP_REST_Response( RemoteRequest::format_error_data( $data ), 503 ); |
| 21 | } |
| 22 | |
| 23 | return new \WP_REST_Response( $data ); |
| 24 | } |
| 25 | } |