From 7df08d17e8b1f2eb87a5177c2d31c75c23c113b9 Mon Sep 17 00:00:00 2001
From: Alex Standiford
Date: Sun, 21 Nov 2021 19:05:46 -0600
Subject: [PATCH 1/3] Compat for Underpin 2.0.0
---
Rest_Endpoint.php | 2 +-
rest-endpoints.php | 11 ++++++++---
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/Rest_Endpoint.php b/Rest_Endpoint.php
index f4b00df..3d28655 100644
--- a/Rest_Endpoint.php
+++ b/Rest_Endpoint.php
@@ -23,7 +23,7 @@
*
* @package Underpin\Abstracts
*/
-abstract class Rest_Endpoint {
+abstract class Rest_Endpoint extends \WP_REST_Controller {
use Feature_Extension;
/**
diff --git a/rest-endpoints.php b/rest-endpoints.php
index a72d838..eb8d571 100644
--- a/rest-endpoints.php
+++ b/rest-endpoints.php
@@ -1,14 +1,19 @@
function ( Underpin $plugin ) {
require_once( plugin_dir_path( __FILE__ ) . 'Rest_Endpoint.php' );
require_once( plugin_dir_path( __FILE__ ) . 'Rest_Endpoint_Instance.php' );
- Underpin\underpin()->get( $file, $class )->loaders()->add( 'rest_endpoints', [
+ $plugin->loaders()->add( 'rest_endpoints', [
'instance' => 'Underpin_Rest_Endpoints\Abstracts\Rest_Endpoint',
'default' => 'Underpin_Rest_Endpoints\Factories\Rest_Endpoint_Instance',
] );
-}, 10, 2 );
\ No newline at end of file
+ },
+] ) );
\ No newline at end of file
From 8461e6f24cde02645f51bc780fd6a9fcf4aa49f7 Mon Sep 17 00:00:00 2001
From: Alex Standiford
Date: Mon, 22 Nov 2021 06:37:10 -0600
Subject: [PATCH 2/3] Corrects composer.json
---
composer.json | 3 +++
1 file changed, 3 insertions(+)
diff --git a/composer.json b/composer.json
index e7cbb5d..46746cd 100644
--- a/composer.json
+++ b/composer.json
@@ -9,6 +9,9 @@
"email": "a@alexstandiford.com"
}
],
+ "require": {
+ "underpin/underpin": "^2.0"
+ },
"autoload": {
"files": [
"rest-endpoints.php"
From c85af7041f157e77e7d07dc0c86d880c9a540a08 Mon Sep 17 00:00:00 2001
From: Alex Standiford
Date: Tue, 23 Nov 2021 08:21:52 -0600
Subject: [PATCH 3/3] Corrects composer.json
---
bootstrap.php | 13 +++++++++++++
composer.json | 3 ++-
.../Abstracts/Rest_Endpoint.php | 9 +++++----
.../Factories/Rest_Endpoint_Instance.php | 4 ++--
rest-endpoints.php | 19 -------------------
5 files changed, 22 insertions(+), 26 deletions(-)
create mode 100644 bootstrap.php
rename Rest_Endpoint.php => lib/Abstracts/Rest_Endpoint.php (94%)
rename Rest_Endpoint_Instance.php => lib/Factories/Rest_Endpoint_Instance.php (86%)
delete mode 100644 rest-endpoints.php
diff --git a/bootstrap.php b/bootstrap.php
new file mode 100644
index 0000000..2204d75
--- /dev/null
+++ b/bootstrap.php
@@ -0,0 +1,13 @@
+ 'Underpin\Rest_Endpoints\Abstracts\Rest_Endpoint',
+ 'default' => 'Underpin\Rest_Endpoints\Factories\Rest_Endpoint_Instance',
+] ) );
\ No newline at end of file
diff --git a/composer.json b/composer.json
index 46746cd..aa6cf42 100644
--- a/composer.json
+++ b/composer.json
@@ -13,8 +13,9 @@
"underpin/underpin": "^2.0"
},
"autoload": {
+ "psr-4": {"Underpin\\Rest_Endpoints\\": "lib/"},
"files": [
- "rest-endpoints.php"
+ "bootstrap.php"
]
}
}
diff --git a/Rest_Endpoint.php b/lib/Abstracts/Rest_Endpoint.php
similarity index 94%
rename from Rest_Endpoint.php
rename to lib/Abstracts/Rest_Endpoint.php
index 3d28655..25c7025 100644
--- a/Rest_Endpoint.php
+++ b/lib/Abstracts/Rest_Endpoint.php
@@ -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;
@@ -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',
diff --git a/Rest_Endpoint_Instance.php b/lib/Factories/Rest_Endpoint_Instance.php
similarity index 86%
rename from Rest_Endpoint_Instance.php
rename to lib/Factories/Rest_Endpoint_Instance.php
index 3c55629..791918c 100644
--- a/Rest_Endpoint_Instance.php
+++ b/lib/Factories/Rest_Endpoint_Instance.php
@@ -1,10 +1,10 @@
function ( Underpin $plugin ) {
- require_once( plugin_dir_path( __FILE__ ) . 'Rest_Endpoint.php' );
- require_once( plugin_dir_path( __FILE__ ) . 'Rest_Endpoint_Instance.php' );
- $plugin->loaders()->add( 'rest_endpoints', [
- 'instance' => 'Underpin_Rest_Endpoints\Abstracts\Rest_Endpoint',
- 'default' => 'Underpin_Rest_Endpoints\Factories\Rest_Endpoint_Instance',
- ] );
- },
-] ) );
\ No newline at end of file