public function WorkflowTransition::setValues in Workflow 7.2
Helper function for __construct. Used for all children of WorkflowTransition (aka WorkflowScheduledTransition)
Parameters
$entity_type:
$entity:
$field_name:
$old_sid:
$new_sid:
null $uid:
int $stamp:
string $comment:
1 call to WorkflowTransition::setValues()
- WorkflowScheduledTransition::setValues in includes/
Entity/ WorkflowScheduledTransition.php - Helper function for __construct. Used for all children of WorkflowTransition (aka WorkflowScheduledTransition)
1 method overrides WorkflowTransition::setValues()
- WorkflowScheduledTransition::setValues in includes/
Entity/ WorkflowScheduledTransition.php - Helper function for __construct. Used for all children of WorkflowTransition (aka WorkflowScheduledTransition)
File
- includes/
Entity/ WorkflowTransition.php, line 93 - Contains workflow\includes\Entity\WorkflowTransition. Contains workflow\includes\Entity\WorkflowTransitionController.
Class
- WorkflowTransition
- Implements an actual Transition.
Code
public function setValues($entity_type, $entity, $field_name, $old_sid, $new_sid, $uid = NULL, $stamp = REQUEST_TIME, $comment = '') {
// Normally, the values are passed in an array, and set in parent::__construct, but we do it ourselves.
// (But there is no objection to do it there.)
global $user;
$this->entity_type = !$entity_type ? $this->entity_type : $entity_type;
$this->field_name = !$field_name ? $this->field_name : $field_name;
$uid = $uid === NULL ? $user->uid : $uid;
// If constructor is called with new() and arguments.
// Load the supplied entity.
if ($entity && !$entity_type) {
// Not all parameters are passed programmatically.
drupal_set_message(t('Wrong call to new Workflow*Transition()'), 'error');
}
elseif ($entity) {
$this
->setEntity($entity_type, $entity);
}
if (!$entity && !$old_sid && !$new_sid) {
// If constructor is called without arguments, e.g., loading from db.
}
elseif ($entity && $old_sid) {
// Caveat: upon entity_delete, $new_sid is '0'.
// If constructor is called with new() and arguments.
$this->old_sid = $old_sid;
$this->sid = $new_sid;
$this->uid = $uid;
$this->stamp = $stamp;
$this->comment = $comment;
// Set language. Multi-language is not supported for Workflow Node.
$this->language = _workflow_metadata_workflow_get_properties($entity, array(), 'langcode', $entity_type, $field_name);
}
elseif (!$old_sid) {
// Not all parameters are passed programmatically.
drupal_set_message(t('Wrong call to constructor Workflow*Transition(@old_sid to @new_sid)', array(
'@old_sid' => $old_sid,
'@new_sid' => $new_sid,
)), 'error');
}
// Fill the 'new' fields correctly. @todo D8: rename these fields in db table.
$this->entity_id = $this->nid;
$this->new_sid = $this->sid;
// Initialize wid, if not set.
if ($this->old_sid && !$this->wid) {
$this
->getWorkflow();
}
}