/**
  * Implement the save function for the entity.
  */
 public function entity_save($entity)
 {
     if (module_exists('workbench_moderation') && workbench_moderation_node_type_moderated($entity->type)) {
         $live_entity = workbench_moderation_node_live_load($entity);
         if ($live_entity->vid != $entity->vid) {
             $entity->revision = TRUE;
         }
     }
     node_save($entity);
 }
 /**
  * Grab a named node from the entity store and add moderation fields to it.
  *
  * @param String $name A named entity in the entity store.
  * @return \StdClass Node with additional moderation fields.
  * @throws \Exception
  */
 public function getModerationNode($name)
 {
     /** @var \EntityDrupalWrapper $wrapper */
     $wrapper = $this->getEntityStore()->retrieve_by_name($name);
     if ($wrapper === FALSE) {
         throw new \Exception("No entity with the name '{$name}' was found. Make sure it's created in the step.");
     }
     if ($wrapper->type() !== 'node') {
         $entity_type = $wrapper->type();
         throw new \Exception("Only nodes types are supported by workbench_moderation, but {$entity_type} type given.");
     }
     if (!workbench_moderation_node_type_moderated($wrapper->getBundle())) {
         $types = implode(', ', workbench_moderation_moderate_node_types());
         throw new \Exception("Nodes type '{$wrapper->getBundle()}' is not a moderated type. Types enabled are [{$types}]'.");
     }
     $node = $wrapper->raw();
     workbench_moderation_node_data($node);
     return $node;
 }