From 9d50577f51b0790b09333aae91f7771edcfcccbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jurij=20Podgor=C5=A1ek?= Date: Fri, 10 May 2024 19:24:46 +0200 Subject: [PATCH] Revert sprememb, reseno na drugem branchu --- .../src/Plugin/rest/resource/AddConcept.php | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/web/modules/custom/yufu_concept/src/Plugin/rest/resource/AddConcept.php b/web/modules/custom/yufu_concept/src/Plugin/rest/resource/AddConcept.php index d8899da..3a75ae5 100644 --- a/web/modules/custom/yufu_concept/src/Plugin/rest/resource/AddConcept.php +++ b/web/modules/custom/yufu_concept/src/Plugin/rest/resource/AddConcept.php @@ -90,11 +90,11 @@ class AddConcept extends ResourceBase { } /** - * Ustvari nov ali uredi obstoječ koncept. + * Ustvari nov koncept. * * Logika: * 1. Zloadamo uporabnika preko emaila, ce ne obstaja, ga ustvarimo. - * 2. Zloadamo koncept prek uuid, ce ne obstaja, ga ustvarimo. + * 2. Zloadamo koncept prek uuid, ce ne obstaja, da ustvarimo. * - avtor je zloadan prek maila * * @param \Symfony\Component\HttpFoundation\Request; @@ -117,14 +117,11 @@ class AddConcept extends ResourceBase { throw new MissingDataException('Title, uuid or text missing.'); } $uid = $this->getUserIdByEmail($data['email'] ?? null); - // @TODO - loudaj zadnjo revizijo in primerjaj z entiteto, je - // razlika? - // Kako dodati revizijo, ki je draft? if ($concept = $this->getConceptFromUuid($data['uuid'])) { // Concept exists - create a new revision. - $oldConcept = clone $concept; - $concept->setNewRevision(TRUE); + $concept->setRevisionUserId($uid); + $concept->setRevisionCreationTime(\Drupal::time()->getRequestTime()); $concept->set('title', $data['title']); $concept->set('body', $data['text'] ?? $concept->body->value); if ($uid) { @@ -142,12 +139,8 @@ class AddConcept extends ResourceBase { '@revid' => $concept->getRevisionId(), '@uid' => $uid, ]); - - /* - $oldConcept->isDefaultRevision(TRUE); - $oldConcept->save(); - */ - } else { + } + else { // Concept does not exist - create a new node. $concept = [ 'type' => 'concept',