Make BaseModule a real entity

- Add all dependencies, necessary to run the content (baseUrl, Arguments)
- Encapsulate all POST/GET/DELETE/PATCH/PUT methods as protected methods inside the BaseModule
- Return Module content ONLY per `BaseModule::run()` (including the Hook logic there as well)
This commit is contained in:
Philipp 2021-11-20 15:38:03 +01:00
parent 238613fd01
commit 8bdd90066f
No known key found for this signature in database
GPG key ID: 24A7501396EB5432
252 changed files with 615 additions and 623 deletions

View file

@ -2,59 +2,20 @@
namespace Friendica\Capabilities;
use Friendica\Network\HTTPException;
/**
* This interface provides the capability to handle requests from clients and returns the desired outcome
*/
interface ICanHandleRequests
{
/**
* Module GET method to display raw content from technical endpoints
* @param array $post The $_POST content (in case of POST)
* @param array $request The $_REQUEST content (in case of GET, POST)
*
* Extend this method if the module is supposed to return communication data,
* e.g. from protocol implementations.
*/
public function rawContent();
/**
* Module GET method to display any content
* @return string Returns the content of the module as string
*
* Extend this method if the module is supposed to return any display
* through a GET request. It can be an HTML page through templating or a
* XML feed or a JSON output.
* @throws HTTPException\InternalServerErrorException
*/
public function content(): string;
/**
* Module DELETE method to process submitted data
*
* Extend this method if the module is supposed to process DELETE requests.
* Doesn't display any content
*/
public function delete();
/**
* Module PATCH method to process submitted data
*
* Extend this method if the module is supposed to process PATCH requests.
* Doesn't display any content
*/
public function patch();
/**
* Module POST method to process submitted data
*
* Extend this method if the module is supposed to process POST requests.
* Doesn't display any content
*/
public function post();
/**
* Module PUT method to process submitted data
*
* Extend this method if the module is supposed to process PUT requests.
* Doesn't display any content
*/
public function put();
public function getClassName(): string;
public function run(array $post = [], array $request = []): string;
}