コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public static function getPreviousStateId(EntityInterface $entity, $field_name = '')
 {
     $sid = '';
     if (!$entity) {
         return $sid;
     }
     // If $field_name is not known, yet, determine it.
     $field_name = $field_name ? $field_name : workflow_get_field_name($entity, $field_name);
     // If $field_name is found, get more details.
     if (!$field_name) {
         // Return the initial value.
         return $sid;
     }
     if (isset($entity->original)) {
         // A changed node.
         workflow_debug(__FILE__, __FUNCTION__, __LINE__, $sid);
         // @todo D8-port: still test this snippet.
     }
     // A node may not have a Workflow attached.
     if ($entity->isNew()) {
         // A new Node. D7: $is_new is not set when saving terms, etc.
         $sid = self::getCreationStateId($entity, $field_name);
     } elseif (!$sid) {
         // @todo?: Read the history with an explicit langcode.
         $langcode = '';
         // $entity->language()->getId();
         $entity_type = $entity->getEntityTypeId();
         if ($last_transition = WorkflowTransition::loadByProperties($entity_type, $entity->id(), [], $field_name, $langcode, 'DESC')) {
             $sid = $last_transition->getFromSid();
         }
     }
     if (!$sid) {
         // No history found on an existing entity.
         $sid = self::getCreationStateId($entity, $field_name);
     }
     return $sid;
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public static function loadByProperties($entity_type, $entity_id, array $revision_ids = [], $field_name = '', $langcode = '', $sort = 'ASC', $transition_type = 'workflow_scheduled_transition')
 {
     // N.B. $transition_type is set as parameter default.
     return parent::loadByProperties($entity_type, $entity_id, $revision_ids, $field_name, $langcode, $sort, $transition_type);
 }