Replace IRespondToRequests with PSR-7 ResponseInterface

This commit is contained in:
Philipp 2021-11-21 23:37:17 +01:00
parent ca5c40c97e
commit 7cd85873ee
No known key found for this signature in database
GPG key ID: 24A7501396EB5432
17 changed files with 96 additions and 92 deletions

View file

@ -3,9 +3,24 @@
namespace Friendica\Capabilities;
use Friendica\Network\HTTPException\InternalServerErrorException;
use Psr\Http\Message\ResponseInterface;
interface ICanCreateResponses extends IRespondToRequests
interface ICanCreateResponses
{
const TYPE_HTML = 'html';
const TYPE_XML = 'xml';
const TYPE_JSON = 'json';
const TYPE_ATOM = 'atom';
const TYPE_RSS = 'rss';
const ALLOWED_TYPES = [
self::TYPE_HTML,
self::TYPE_XML,
self::TYPE_JSON,
self::TYPE_ATOM,
self::TYPE_RSS
];
/**
* Adds a header entry to the module response
*
@ -30,4 +45,12 @@ interface ICanCreateResponses extends IRespondToRequests
* @throws InternalServerErrorException
*/
public function setType(string $type, ?string $content_type = null): void;
/**
* Creates a PSR-7 compliant interface
* @see https://www.php-fig.org/psr/psr-7/
*
* @return ResponseInterface
*/
public function generate(): ResponseInterface;
}

View file

@ -3,6 +3,7 @@
namespace Friendica\Capabilities;
use Friendica\Network\HTTPException;
use Psr\Http\Message\ResponseInterface;
/**
* This interface provides the capability to handle requests from clients and returns the desired outcome
@ -13,9 +14,9 @@ interface ICanHandleRequests
* @param array $post The $_POST content (in case of POST)
* @param array $request The $_REQUEST content (in case of GET, POST)
*
* @return IRespondToRequests responding to the request handling
* @return ResponseInterface responding to the request handling
*
* @throws HTTPException\InternalServerErrorException
*/
public function run(array $post = [], array $request = []): IRespondToRequests;
public function run(array $post = [], array $request = []): ResponseInterface;
}

View file

@ -1,41 +0,0 @@
<?php
namespace Friendica\Capabilities;
interface IRespondToRequests
{
const TYPE_HTML = 'html';
const TYPE_XML = 'xml';
const TYPE_JSON = 'json';
const TYPE_ATOM = 'atom';
const TYPE_RSS = 'rss';
const ALLOWED_TYPES = [
self::TYPE_HTML,
self::TYPE_XML,
self::TYPE_JSON,
self::TYPE_ATOM,
self::TYPE_RSS
];
/**
* Returns all set headers during the module execution
*
* @return string[]
*/
public function getHeaders(): array;
/**
* Returns the output of the module (mixed content possible)
*
* @return mixed
*/
public function getContent();
/**
* Returns the response type
*
* @return string
*/
public function getType(): string;
}