. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU Affero General Public License version 3. * * In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ namespace Espo\Core\Api; use Slim\Psr7\Factory\ResponseFactory; use Espo\Core\Utils\Json; use stdClass; class ResponseComposer { /** * Compose a JSON response. * * @param array|stdClass|scalar|null $data A data to encode. */ public static function json(mixed $data): Response { return self::empty() ->writeBody(Json::encode($data)) ->setHeader('Content-Type', 'application/json'); } /** * Compose an empty response. */ public static function empty(): Response { $psr7Response = (new ResponseFactory())->createResponse(); return new ResponseWrapper($psr7Response); } }