feat(ApiAware): use this interface
This commit is contained in:
parent
78902e0502
commit
a5f0581535
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
// Authors: see README.md
|
||||
|
||||
use SeaCMS\Api\ApiAware;
|
||||
use SeaCMS\Api\BadMethodException;
|
||||
use SeaCMS\Api\JsonResponse;
|
||||
use SeaCMS\Api\NotFoundRouteException;
|
||||
@ -9,7 +10,7 @@ use SeaCMS\Api\NotFoundRouteException;
|
||||
/**
|
||||
* An api plugin for Pico 3.
|
||||
*/
|
||||
class SeacmsApi extends AbstractPicoPlugin
|
||||
class SeacmsApi extends AbstractPicoPlugin implements ApiAware
|
||||
{
|
||||
/**
|
||||
* Pico API version.
|
||||
@ -67,7 +68,7 @@ class SeacmsApi extends AbstractPicoPlugin
|
||||
{
|
||||
$this->routesOnPageRendered = [];
|
||||
foreach($plugins as $plugin){
|
||||
if (method_exists($plugin,'registerOnPageRenderedApiRoutes')){
|
||||
if ($plugin instanceof ApiAware){
|
||||
$routes = $plugin->registerOnPageRenderedApiRoutes();
|
||||
if (is_array($routes)){
|
||||
foreach($routes as $route => $methodName){
|
||||
|
17
src/ApiAware.php
Normal file
17
src/ApiAware.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
// Authors: see README.md
|
||||
|
||||
namespace SeaCMS\Api;
|
||||
|
||||
/**
|
||||
* Response for http response
|
||||
*/
|
||||
interface ApiAware
|
||||
{
|
||||
/**
|
||||
* return api routes
|
||||
* @return array
|
||||
*/
|
||||
public function registerOnPageRenderedApiRoutes():array;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user