diff --git a/web/modules/custom/yufu_admin/yufu_admin.module b/web/modules/custom/yufu_admin/yufu_admin.module index d88736c..95a9531 100644 --- a/web/modules/custom/yufu_admin/yufu_admin.module +++ b/web/modules/custom/yufu_admin/yufu_admin.module @@ -130,13 +130,13 @@ function _yufu_admin_concept_drafted_mail(NodeInterface $node) { if ($node->isNew()) { $params['message'] = t('New concept created: @title - @url', [ '@title' => $node->getTitle(), - '@url' => !$node->isNew() ? $node?->toUrl()?->toString() : '', + '@url' => '', ]); } else { $params['message'] = t('New changes to concept proposed: @title - @url', [ '@title' => $node->getTitle(), - '@url' => !$node->isNew() ? $node?->toUrl()?->toString() : '', + '@url' => $node?->toUrl()?->toString(), ]); } $params['node_title'] = $node->getTitle(); 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 318568c..ca66cde 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 @@ -12,6 +12,7 @@ use Drupal\rest\ResourceResponse; use Psr\Log\LogLevel; use Psr\Log\LoggerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; @@ -125,9 +126,8 @@ class AddConcept extends ResourceBase { $concept->set('body', $data['text'] ?? $concept->body->value); $concept->isDefaultRevision(FALSE); $concept->setRevisionLogMessage('New revision by concept endpoint.'); - $concept->moderation_state->target_id = 'draft'; + $concept->set('moderation_state', 'draft'); $concept->set('status', 0); - $concept->setUnpublished(); $concept->save(); $this->logger->notice('New concept @title revision @revid created by uid @uid.', [ '@title' => $concept->getTitle(), @@ -163,7 +163,8 @@ class AddConcept extends ResourceBase { 'revision_uid' => $concept->getRevisionUserId(), 'uid' => $concept->uid->target_id, ]; - $response = new ResourceResponse($response_status); + // $response = new ResourceResponse($response_status); + $response = new JsonResponse($response_status); return $response; } @@ -182,7 +183,8 @@ class AddConcept extends ResourceBase { return NULL; } $node_storage = $this->entityTypeManager->getStorage('node'); - if ($concept = end($node_storage->loadByProperties(['uuid' => $uuid]))) { + $concepts = $node_storage->loadByProperties(['uuid' => $uuid]); + if ($concept = end($concepts)) { return $concept; } return NULL;