varsitynewsnetwork / wordpress-rest-api-client

A Wordpress API client for PHP
76 stars 64 forks source link

[Feature] Multiple namespaces to look for endpoints #20

Open zoliszabo opened 5 years ago

zoliszabo commented 5 years ago

Adds possibility to define multiple locations (namespaces) where WpClient can look after endpoints. This feature is useful where custom, domain-specific endpoints are used.

How to use:

Your new endpoint (notice the namespace):

namespace Your\Special\Endpoint;

use Vnn\WpApiClient\Endpoint\AbstractWpEndpoint; 

class Examples extends AbstractWpEndpoint
{
...
}

And where it is added to WpClient:

$client = new WpClient(...);
$client->addEndpointNamespace('Your\Special\Endpoint\\');
$client->examples()->get(1);
pekka commented 1 year ago

This PR was a huge help for me today - thank you!

zoliszabo commented 1 year ago

This PR was a huge help for me today - thank you!

You're welcome! :)

zack-carlson commented 1 year ago

https://github.com/varsitynewsnetwork/wordpress-rest-api-client/issues/29#issuecomment-1419711386