Skip to content

Commit

Permalink
Start process of building a base endpoint for pressforward
Browse files Browse the repository at this point in the history
  • Loading branch information
AramZS committed Sep 10, 2016
1 parent f9857c6 commit b9331b8
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
36 changes: 36 additions & 0 deletions Core/API/DiscoveryEndpoint.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
namespace PressForward\Core\API;

use Intraxia\Jaxion\Contract\Core\HasActions;
use Intraxia\Jaxion\Contract\Core\HasFilters;

use PressForward\Controllers\Metas;
use WP_REST_Posts_Controller;

use WP_Ajax_Response;

class DiscoveryEndpoint extends WP_REST_Posts_Controller implements HasActions {

protected $basename;

function __construct( Metas $metas, $vendor, $api_version ){
$this->namespace = $vendor.'/'.$api_version;
}


public function action_hooks() {
$actions = array(
array(
'hook' => 'rest_api_init',
'method' => 'register_rest_namespace',
)
);
return $actions;
}

public function register_rest_namespace(){
register_rest_route( $this->namespace, '/', array( 'test' => 'go' ) );
}


}
12 changes: 12 additions & 0 deletions Core/Providers/APIProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,22 @@
use PressForward\Core\API\PostExtension;
use PressForward\Core\API\FeedEndpoint;
use PressForward\Core\API\ItemEndpoint;
use PressForward\Core\API\DiscoveryEndpoint;


class APIProvider extends ServiceProvider {

public function register( Container $container ){
$this->vendor = 'pf';
$this->api_version = 'v1';

$container->share(
'api.discovery_endpoint',
function( $container ){
return new DiscoveryEndpoint( $container->fetch('controller.metas'), $this->vendor, $this->api_version );
}
);

$container->share(
'api.post_extension',
function( $container ){
Expand All @@ -32,6 +43,7 @@ function( $container ){
return new ItemEndpoint( $container->fetch('controller.metas') );
}
);

}

}

0 comments on commit b9331b8

Please sign in to comment.