]> git.mxchange.org Git - friendica.git/blobdiff - src/Capabilities/ICanCreateResponses.php
Merge pull request #11136 from urbalazs/error-message-translation
[friendica.git] / src / Capabilities / ICanCreateResponses.php
index 282458136bb58aae726a4fd71e5f4ebf94631d7b..f0dac471f5ba8f99a6fba447d2562f40f83cfbcb 100644 (file)
@@ -1,11 +1,50 @@
 <?php
+/**
+ * @copyright Copyright (C) 2010-2022, the Friendica project
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
 
 namespace Friendica\Capabilities;
 
 use Friendica\Network\HTTPException\InternalServerErrorException;
+use Psr\Http\Message\ResponseInterface;
 
-interface ICanCreateResponses extends IRespondToRequests
+interface ICanCreateResponses
 {
+       /**
+        * This constant helps to find the specific return type of responses inside the headers array
+        */
+       const X_HEADER = 'X-RESPONSE-TYPE';
+
+       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 +69,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;
 }