diff --git a/docs/cms-api.md b/docs/cms-api.md index c28122c..67bbfb4 100644 --- a/docs/cms-api.md +++ b/docs/cms-api.md @@ -104,8 +104,9 @@ Configuration (extension configuration `ep_products`, tab ContentFeed): `content n8n writes the JSON-LD (SEO markup) of a content element (`EP\EpProducts\JsonLd\JsonLdApi`). n8n is the source of truth: the element's `bodytext` is replaced with the posted object wrapped in -`" inside a value must not end the script element private const int JSON_FLAGS = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_HEX_TAG | JSON_THROW_ON_ERROR; @@ -46,13 +50,17 @@ class JsonLdApi $uid = substr($request->getUri()->getPath(), strlen(self::PATH_PREFIX)); $record = 1 === preg_match('/^[1-9]\d*$/', $uid) - ? BackendUtility::getRecord('tt_content', (int) $uid, 'uid,pid,bodytext') + ? BackendUtility::getRecord('tt_content', (int) $uid, 'uid,pid,CType,bodytext') : null; if (null === $record) { return new JsonResponse(['message' => 'Content element not found'], 404); } + if (self::CTYPE !== $record['CType']) { + return new JsonResponse(['message' => 'Content element is of type "' . $record['CType'] . '", only "' . self::CTYPE . '" is written'], 409); + } + try { // Decoded as objects, not arrays, so an empty {} stays an object $jsonLd = json_decode((string) $request->getBody(), false, 512, JSON_THROW_ON_ERROR);