updateValues() public method

public updateValues ( array $values = [] ) : boolean
$values array
return boolean
Exemplo n.º 1
0
 /**
  * Update the mapping specification for an automatic worklist definition.
  *
  * @param WorklistDefinitionMapping $mapping
  * @param $key
  * @param string $values
  *
  * @return bool
  */
 public function updateWorklistDefinitionMapping(WorklistDefinitionMapping $mapping, $key, $values, $display = true)
 {
     $values = strlen($values) ? explode(',', $values) : array();
     $definition = $mapping->worklist_definition;
     if (!$this->canUpdateWorklistDefinition($definition)) {
         $this->addError('Cannot update mapping for un-editable Worklist Definition');
         return false;
     }
     if (!$definition->validateMappingKey($key, $mapping->id)) {
         $this->addError("Mapping key {$key} already exists for definition");
         return false;
     }
     $mapping->key = $key;
     if (!$display) {
         $mapping->display_order = null;
     } elseif (!$mapping->display_order) {
         $mapping->display_order = $definition->getNextDisplayOrder();
     }
     $transaction = $this->startTransaction();
     try {
         if (!$mapping->save()) {
             throw new Exception('Could not save mapping');
         }
         if (!$mapping->updateValues($values)) {
             throw new Exception('Could not save mapping values');
         }
         $this->audit(self::$AUDIT_TARGET_AUTO, 'mapping-update');
         if ($transaction) {
             $transaction->commit();
         }
     } catch (Exception $e) {
         $this->addError($e->getMessage());
         echo $e->getMessage();
         if ($transaction) {
             $transaction->rollback();
         }
         return false;
     }
     return true;
 }