Po sprejetih spremembah je uporabnik urednik.

pull/59/head
Lio Novelli 2024-04-01 21:45:04 +02:00
parent 8767ef606b
commit 1ab9d5f2b5
3 changed files with 26 additions and 3 deletions

View File

@ -6,7 +6,8 @@ id: spremembe_sprejete
workflow: concept_workflow
transitions:
publish: publish
roles: { }
roles:
editor: editor
author: true
site_mail: false
emails: ''

View File

@ -8,7 +8,7 @@ use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\TypedData\Exception\MissingDataException;
use Drupal\node\NodeInterface;
use Drupal\rest\Plugin\ResourceBase;
use Drupal\rest\ResourceResponse;
// use Drupal\rest\ResourceResponse;
use Psr\Log\LogLevel;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
@ -127,7 +127,7 @@ class AddConcept extends ResourceBase {
if ($uid) {
$uids = $concept->get('uid')->getValue();
$uids[] = ['target_id' => $uid];
$concept->set('uid', $uids);
$concept->set('uid', array_reverse($uids));
}
$concept->isDefaultRevision(FALSE);
$concept->setRevisionLogMessage('New revision by concept endpoint.');

View File

@ -1,6 +1,28 @@
<?php
use Drupal\Core\Entity\EntityInterface;
use Drupal\node\NodeInterface;
/**
* @file
* Primary module hooks for Yufu Concept module.
*/
/**
* Implements hook_entity_update().
*/
function yufu_concept_entity_update(EntityInterface $entity) {
if ($entity instanceOf NodeInterface && $entity->bundle() == 'concept') {
$transition = \Drupal::service('content_moderation_notifications.notification_information')->getTransition($entity);
if ($transition->id() == 'publish') {
if ($user = $entity->uid->entity) {
if (!$user->status->value) {
$user->set('status', 1);
$user->addRole('editor');
$user->save();
}
}
}
}
}