Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save deepakaryan1988/75bf92ed053f21c7d3e9be31baa15c44 to your computer and use it in GitHub Desktop.
Save deepakaryan1988/75bf92ed053f21c7d3e9be31baa15c44 to your computer and use it in GitHub Desktop.
D8-getting current moderation state
use Drupal\grievance\Entity\GrievanceEntity;
$grievance_id = "4";
$grievance = GrievanceEntity::load($grievance_id);
$grievance_vid = \Drupal::entityManager()->getStorage('grievance')->revisionIds($grievance);
$latest_revision_id = array_pop((array_slice($grievance_vid, -1)));
$grievance_revision = \Drupal::entityTypeManager()
->getStorage('grievance')
->loadRevision($latest_revision_id);
$current_state = $grievance_revision->get('moderation_state')->getValue()['0']['value'];
kint($current_state);exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment