From e8219a3153e87ef732b24bf4df3e2db906057510 Mon Sep 17 00:00:00 2001 From: Robert Jurinek Date: Thu, 30 Nov 2023 12:11:20 +0100 Subject: [PATCH] Allow custom REST API endpoints --- src/Endpoint/AbstractWpEndpoint.php | 2 +- src/Endpoint/Categories.php | 2 +- src/Endpoint/Comments.php | 2 +- src/Endpoint/Custom.php | 19 +++++++++++++++++++ src/Endpoint/FakeEndpoint.php | 2 +- src/Endpoint/Media.php | 2 +- src/Endpoint/Pages.php | 2 +- src/Endpoint/PostStatuses.php | 2 +- src/Endpoint/PostTypes.php | 2 +- src/Endpoint/Posts.php | 2 +- src/Endpoint/Tags.php | 2 +- src/Endpoint/Users.php | 2 +- 12 files changed, 30 insertions(+), 11 deletions(-) create mode 100644 src/Endpoint/Custom.php diff --git a/src/Endpoint/AbstractWpEndpoint.php b/src/Endpoint/AbstractWpEndpoint.php index 8f8e67d..3be171e 100644 --- a/src/Endpoint/AbstractWpEndpoint.php +++ b/src/Endpoint/AbstractWpEndpoint.php @@ -26,7 +26,7 @@ public function __construct(WpClient $client) $this->client = $client; } - abstract protected function getEndpoint(); + abstract protected function getEndpoint($path = ''); /** * @param int $id diff --git a/src/Endpoint/Categories.php b/src/Endpoint/Categories.php index 607d468..ba50ada 100644 --- a/src/Endpoint/Categories.php +++ b/src/Endpoint/Categories.php @@ -11,7 +11,7 @@ class Categories extends AbstractWpEndpoint /** * {@inheritdoc} */ - protected function getEndpoint() + protected function getEndpoint($path = '') { return '/wp-json/wp/v2/categories'; } diff --git a/src/Endpoint/Comments.php b/src/Endpoint/Comments.php index 611e4fe..7d6e932 100644 --- a/src/Endpoint/Comments.php +++ b/src/Endpoint/Comments.php @@ -11,7 +11,7 @@ class Comments extends AbstractWpEndpoint /** * {@inheritdoc} */ - protected function getEndpoint() + protected function getEndpoint($path = '') { return '/wp-json/wp/v2/comments'; } diff --git a/src/Endpoint/Custom.php b/src/Endpoint/Custom.php new file mode 100644 index 0000000..d9e0a38 --- /dev/null +++ b/src/Endpoint/Custom.php @@ -0,0 +1,19 @@ +