Last active
August 3, 2018 15:05
-
-
Save adamfranco/3347950b29d437474aad33dc18f1b3f9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$nids = \Drupal::entityQuery('node')->condition('type', 'event')->condition('status', 0)->execute(); | |
$nodes = entity_load_multiple('node', $nids); | |
foreach ($nodes as $entity) { | |
$entity->set('moderation_state', 'published'); | |
if ($entity instanceof RevisionLogInterface) { | |
$entity->setRevisionLogMessage('Programatically updating workflow state.'); | |
$entity->setRevisionUserId(\Drupal::currentUser()->id()); | |
} | |
$entity->save(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment