Skip to content
Snippets Groups Projects
Commit 8a0735aa authored by Eric Bremner's avatar Eric Bremner Committed by Kevin Paxman
Browse files

ISTWCMS-5133: updating content moderation to include user id when changing moderation state

parent e0884cac
No related branches found
No related tags found
1 merge request!155ISTWCMS-5133: updating content moderation to include user id when changing moderation state
......@@ -7,6 +7,7 @@ use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Session\AccountProxyInterface;
use Drupal\Core\Url;
use Drupal\uw_cfg_common\Service\UWService;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -37,14 +38,22 @@ class UwContentModerationForm extends ConfirmFormBase {
*/
protected $vid;
/**
* The current user.
*
* @var \Drupal\Core\Session\AccountProxyInterface
*/
protected $currentUser;
/**
* Class constructor.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
public function __construct(EntityTypeManagerInterface $entity_type_manager, AccountProxyInterface $currentUser) {
$this->entityTypeManager = $entity_type_manager;
$this->currentUser = $currentUser;
}
/**
......@@ -53,7 +62,8 @@ class UwContentModerationForm extends ConfirmFormBase {
public static function create(ContainerInterface $container) {
// Instantiates this form class.
return new static(
$container->get('entity_type.manager')
$container->get('entity_type.manager'),
$container->get('current_user')
);
}
......@@ -143,6 +153,10 @@ class UwContentModerationForm extends ConfirmFormBase {
// two statesL upublish and draft.
if ($this->status) {
// ISTWCMS-5133: adding the uid to the revision, so that
// the correct user is display for who performed the action.
$node->set('revision_uid', $this->currentUser->id());
// First set the node to unpublished, we need to do this
// because moving it to just draft will not cause it to
// become unpublished.
......@@ -165,6 +179,10 @@ class UwContentModerationForm extends ConfirmFormBase {
// Set the moderation state to publish.
$node->set('moderation_state', 'published');
// ISTWCMS-5133: adding the uid to the revision, so that
// the correct user is display for who performed the action.
$node->set('revision_uid', $this->currentUser->id());
// Save the node with the moderation state at published.
$saved_status = $node->save();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment