public function save($entity, DatabaseTransaction $transaction = NULL)
 {
     $workflow = $entity->getWorkflow();
     // To avoid double posting, check if this transition already exist.
     if (empty($entity->tid)) {
         if ($workflow) {
             $config_transitions = $workflow->getTransitionsBySidTargetSid($entity->sid, $entity->target_sid);
             $config_transition = reset($config_transitions);
             if ($config_transition) {
                 $entity->tid = $config_transition->tid;
             }
         }
     }
     // 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);
     if ($return) {
         // Save in current workflow for the remainder of this page request.
         // Keep in sync with Workflow::getTransitions() !
         $workflow = $entity->getWorkflow();
         if ($workflow) {
             $workflow->transitions[$entity->tid] = $entity;
             // $workflow->sortTransitions();
         }
     }
     // Reset the cache for the affected workflow, to force reload upon next page_load.
     workflow_reset_cache($entity->wid);
     return $return;
 }
 /**
  * Saves a fundraiser sustainers series entity.
  *
  * @param Entity $fundraiser_sustainers_series
  *   The fundraiser sustainers series to save.
  *
  * @return Entity
  *   The saved fundraiser sustainers series.
  */
 public function save($fundraiser_sustainers_series)
 {
     $fundraiser_sustainers_series->updated = time();
     if (isset($fundraiser_sustainers_series->is_new) && $fundraiser_sustainers_series->is_new) {
         $fundraiser_sustainers_series->created = time();
     }
     parent::save($fundraiser_sustainers_series);
     return $fundraiser_sustainers_series;
 }
 /**
  * Override save method.
  *
  * Populate created and updated dates automatically.
  */
 public function save($entity, DatabaseTransaction $transaction = NULL)
 {
     if (isset($entity->is_new)) {
         $entity->created_at = REQUEST_TIME;
     }
     $entity->updated_at = REQUEST_TIME;
     // Always save new revisions.
     $entity->is_new_revision = TRUE;
     return parent::save($entity, $transaction);
 }
 /**
  * Insert (no update) a transition.
  *
  * @deprecated workflow_insert_workflow_node_history() --> WorkflowTransition::save()
  */
 public function save($entity, DatabaseTransaction $transaction = NULL)
 {
     // Check for no transition.
     if ($entity->old_sid == $entity->new_sid) {
         if (!$entity->comment) {
             // Write comment into history though.
             return;
         }
     }
     // Make sure we haven't already inserted history for this update.
     $last_history = workflow_transition_load_single($entity->entity_type, $entity->entity_id, $entity->field_name, $entity->language);
     if ($last_history && $last_history->stamp == REQUEST_TIME && $last_history->new_sid == $entity->new_sid) {
         return;
     } else {
         unset($entity->hid);
         $entity->stamp = REQUEST_TIME;
         return parent::save($entity, $transaction);
     }
 }
Ejemplo n.º 5
0
 public function save($entity, DatabaseTransaction $transaction = NULL)
 {
     // Create the machine_name.
     if (empty($entity->name)) {
         if ($label = $entity->state) {
             $entity->name = str_replace(' ', '_', strtolower($label));
         } else {
             $entity->name = 'state_' . $entity->sid;
         }
     }
     $return = parent::save($entity, $transaction);
     if ($return) {
         $workflow = $entity->getWorkflow();
         // Maintain the new object in the workflow.
         $workflow->states[$entity->sid] = $entity;
     }
     // Reset the cache for the affected workflow.
     workflow_reset_cache($entity->wid);
     return $return;
 }
Ejemplo n.º 6
0
 /**
  * Insert (no update) a transition.
  *
  * deprecated workflow_insert_workflow_node_history() --> WorkflowTransition::save()
  */
 public function save($entity, DatabaseTransaction $transaction = NULL)
 {
     // Check for no transition.
     if ($entity->old_sid == $entity->new_sid) {
         if (!$entity->comment) {
             // Write comment into history though.
             return;
         }
     }
     if (empty($entity->hid)) {
         // Insert the transition. Make sure it hasn't already been inserted.
         $last_history = workflow_transition_load_single($entity->entity_type, $entity->entity_id, $entity->field_name, $entity->language);
         if ($last_history && $last_history->stamp == REQUEST_TIME && $last_history->new_sid == $entity->new_sid) {
             return;
         } else {
             unset($entity->hid);
             $entity->stamp = isset($entity->stamp) ? $entity->stamp : REQUEST_TIME;
             return parent::save($entity, $transaction);
         }
     } else {
         // Update the transition.
         return parent::save($entity, $transaction);
     }
 }