Skip to content

Commit

Permalink
Merge commit 'c85af70'
Browse files Browse the repository at this point in the history
  • Loading branch information
alexstandiford committed Nov 23, 2021
2 parents 01fb7e7 + c85af70 commit 725af70
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 22 deletions.
13 changes: 13 additions & 0 deletions bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

use Underpin\Abstracts\Underpin;

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

// Add this loader.
Underpin::attach( 'setup', new \Underpin\Factories\Observers\Loader( 'rest_endpoints', [
'instance' => 'Underpin\Rest_Endpoints\Abstracts\Rest_Endpoint',
'default' => 'Underpin\Rest_Endpoints\Factories\Rest_Endpoint_Instance',
] ) );
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@
"email": "[email protected]"
}
],
"require": {
"underpin/underpin": "^2.0"
},
"autoload": {
"psr-4": {"Underpin\\Rest_Endpoints\\": "lib/"},
"files": [
"rest-endpoints.php"
"bootstrap.php"
]
}
}
11 changes: 6 additions & 5 deletions Rest_Endpoint.php → lib/Abstracts/Rest_Endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
* @package Underpin\Abstracts
*/

namespace Underpin_Rest_Endpoints\Abstracts;
namespace Underpin\Rest_Endpoints\Abstracts;

use Underpin\Loaders\Logger;
use Underpin\Traits\Feature_Extension;
use WP_REST_Request;
use function Underpin\underpin;


if ( ! defined( 'ABSPATH' ) ) {
exit;
Expand All @@ -23,7 +24,7 @@
*
* @package Underpin\Abstracts
*/
abstract class Rest_Endpoint {
abstract class Rest_Endpoint extends \WP_REST_Controller {
use Feature_Extension;

/**
Expand Down Expand Up @@ -85,14 +86,14 @@ public function register() {
$registered = register_rest_route( $this->rest_namespace, $this->route, $this->args );

if ( false === $registered ) {
underpin()->logger()->log(
Logger::log(
'error',
'rest_route_was_not_registered',
'The rest route ' . $this->route . ' was not registered. There is probably a __doing_it_wrong notice explaining this further.',
[ 'route' => $this->route, 'namespace' => $this->rest_namespace, 'args' => $this->args ]
);
} else {
underpin()->logger()->log(
Logger::log(
'notice',
'rest_route_registered',
'The rest route ' . $this->route . ' was registered successfully',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Underpin_Rest_Endpoints\Factories;
namespace Underpin\Rest_Endpoints\Factories;


use Underpin\Traits\Instance_Setter;
use Underpin_Rest_Endpoints\Abstracts\Rest_Endpoint;
use Underpin\Rest_Endpoints\Abstracts\Rest_Endpoint;
use WP_REST_Request;

if ( ! defined( 'ABSPATH' ) ) {
Expand Down
14 changes: 0 additions & 14 deletions rest-endpoints.php

This file was deleted.

0 comments on commit 725af70

Please sign in to comment.