]> git.mxchange.org Git - friendica.git/blob - src/Capabilities/ICanCreateResponses.php
Replace IRespondToRequests with PSR-7 ResponseInterface
[friendica.git] / src / Capabilities / ICanCreateResponses.php
1 <?php
2
3 namespace Friendica\Capabilities;
4
5 use Friendica\Network\HTTPException\InternalServerErrorException;
6 use Psr\Http\Message\ResponseInterface;
7
8 interface ICanCreateResponses
9 {
10         const TYPE_HTML = 'html';
11         const TYPE_XML  = 'xml';
12         const TYPE_JSON = 'json';
13         const TYPE_ATOM = 'atom';
14         const TYPE_RSS  = 'rss';
15
16         const ALLOWED_TYPES = [
17                 self::TYPE_HTML,
18                 self::TYPE_XML,
19                 self::TYPE_JSON,
20                 self::TYPE_ATOM,
21                 self::TYPE_RSS
22         ];
23
24         /**
25          * Adds a header entry to the module response
26          *
27          * @param string $header
28          * @param string|null $key
29          */
30         public function setHeader(string $header, ?string $key = null): void;
31
32         /**
33          * Adds output content to the module response
34          *
35          * @param mixed $content
36          */
37         public function addContent($content): void;
38
39         /**
40          * Sets the response type of the current request
41          *
42          * @param string $type
43          * @param string|null $content_type (optional) overrides the direct content_type, otherwise set the default one
44          *
45          * @throws InternalServerErrorException
46          */
47         public function setType(string $type, ?string $content_type = null): void;
48
49         /**
50          * Creates a PSR-7 compliant interface
51          * @see https://www.php-fig.org/psr/psr-7/
52          *
53          * @return ResponseInterface
54          */
55         public function generate(): ResponseInterface;
56 }