Commit f9abfd49 authored by John Voskuilen's avatar John Voskuilen
Browse files

Issue #0073412: Fixed a long-standing issue by adding a machine_name and label...

Issue #0073412: Fixed a long-standing issue by adding a machine_name and label for Transitions! Many thanks to workflow_named_transitions.
parent 51e025c2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -512,3 +512,4 @@ Issue #2241577: Added machine_name to Workflow, influencing features.
Issue #2240009: Removed dpm().
Issue #2240009: Fixed 'chained' tokens now also workf when saving entities.
Issue #2226781: Fixed new states add added at end of state list.
Issue #0073412: Fixed a long-standing issue by adding a machine_name and label for Transitions! Many thanks to workflow_named_transitions.
+16 −7
Original line number Diff line number Diff line
@@ -99,15 +99,23 @@ class Workflow extends Entity {

  /**
   * Given information, update or insert a new workflow.
   *
   * This also handles importing, rebuilding, reverting from Features, 
   * as defined in workflow.features.inc.
   * todo: reverting does not refresh States and transitions, since no
   * machine_name was present. As of 7.x-2.3, the machine_name exists in 
   * Workflow and WorkflowConfigTransition, so rebuilding is possible.
   *
   * When changing this function, test with the following situations:
   * - maintain Workflow in Admin UI;
   * - clone Workflow in Admin UI;
   * - create/revert/rebuild Workflow with Features; @see workflow.features.inc
   * - save Workflow programmatically;
   */
  public function save($create_creation_state = TRUE) {
    // When changing this function, test with the following situations:
    // - maintain Workflow in Admin UI;
    // - clone Workflow in Admin UI;
    // - create Workflow with Features;
    // - save Workflow programmatically;

    // Are we saving a new Workflow?
    $is_new = !empty($this->is_new);
    // Are we rebuilding, reverting a new Workflow? @see workflow.features.inc
    $is_rebuild = !empty($this->is_rebuild);
    $is_reverted = !empty($this->is_reverted);

@@ -117,7 +125,8 @@ class Workflow extends Entity {
      unset($this->module);
    }
    else {
      if ($role_map = $this->system_roles) {
      $role_map = isset($this->system_roles) ? $this->system_roles : array();
      if ($role_map) {
        // Remap roles. They can come from another system with shifted role IDs.
        // See also https://drupal.org/node/1702626 .
        $this->tab_roles = _workflow_rebuild_roles($this->tab_roles, $role_map);
+5 −1
Original line number Diff line number Diff line
@@ -37,6 +37,10 @@ class WorkflowConfigTransitionController extends EntityAPIController {
        }
      }
    }
    // Create the machine_name. This can be used to rebuild/revert the Feature in a target system.
    if (empty($entity->name)) {
      $entity->name = $entity->sid . '_'. $entity->target_sid;
    }
    $return = parent::save($entity, $transaction);

    // Reset the cache for the affected workflow.
@@ -88,7 +92,7 @@ class WorkflowConfigTransition extends Entity {
  }

  protected function defaultLabel() {
    return ''; // $this->title;
    return $this->label;
  }

  protected function defaultUri() {
+6 −2
Original line number Diff line number Diff line
@@ -359,16 +359,20 @@ class WorkflowState extends Entity {
        if (!in_array(FALSE, $permitted, TRUE)) {
          // If not vetoed, add to list (by replacing the object by the name).
          if ($target_state = $workflow->getState($new_sid)) {
            $options[$new_sid] = check_plain(t($target_state->label()));
            $label = $transition->label() ? $transition->label() : $target_state->label();
            $options[$new_sid] = check_plain(t($label));
          }
        }
      }
      // Include current state for same-state transitions (by replacing the object by the name).
      // Caveat: this unnecessary since 7.x-2.3 (where stay-on-state transitions are saved, too.)
      // but only if the transitions are saved once.
      if ($current_sid != $workflow->getCreationSid()) {
        if ($current_state = $workflow->getState($current_sid)) {
        if (!isset($options[$current_sid]) && $current_state = $workflow->getState($current_sid)) {
          $options[$current_sid] = check_plain(t($current_state->label()));
        }
      }

      // Remove the unpermitted options.
      foreach ($options as $key => $data) {
        if (is_object($data) ) {
+4 −0
Original line number Diff line number Diff line
@@ -3,6 +3,10 @@
/**
 * @file
 * Provides Features integration for Workflow using the CRUD API.
 *
 * As you will notice this file will only handle the <export> of Worflows, 
 * including states and transitions. The <import> is handeled magically, 
 * and all modifications are done in function Workflow::save().
 */

define('WORKFLOW_FEATURES_AUTHOR_NAME', 'workflow_features_author_name');
Loading