/** * Update Web Entry * * @param string $webEntryUid Unique id of Web Entry * @param string $userUidUpdater Unique id of updater User * @param array $arrayData Data * * return array Return data of the Web Entry updated */ public function update($webEntryUid, $userUidUpdater, array $arrayData) { try { //Verify data $process = new \ProcessMaker\BusinessModel\Process(); $validator = new \ProcessMaker\BusinessModel\Validator(); $validator->throwExceptionIfDataIsNotArray($arrayData, "\$arrayData"); $validator->throwExceptionIfDataIsEmpty($arrayData, "\$arrayData"); //Set data $arrayData = array_change_key_case($arrayData, CASE_UPPER); //Set variables $arrayWebEntryData = $this->getWebEntry($webEntryUid, true); //Verify data $this->throwExceptionIfNotExistsWebEntry($webEntryUid, $this->arrayFieldNameForException["webEntryUid"]); $this->throwExceptionIfDataIsInvalid($webEntryUid, $arrayWebEntryData["PRO_UID"], $arrayData); //Update $cnn = \Propel::getConnection("workflow"); try { $webEntry = \WebEntryPeer::retrieveByPK($webEntryUid); $webEntry->fromArray($arrayData, \BasePeer::TYPE_FIELDNAME); $webEntry->setWeUpdateUsrUid($userUidUpdater); $webEntry->setWeUpdateDate("now"); if ($webEntry->validate()) { $cnn->begin(); $result = $webEntry->save(); $cnn->commit(); //Set WE_TITLE if (isset($arrayData["WE_TITLE"])) { $result = \Content::addContent("WE_TITLE", "", $webEntryUid, SYS_LANG, $arrayData["WE_TITLE"]); } if (isset($arrayData["WE_DESCRIPTION"])) { $result = \Content::addContent("WE_DESCRIPTION", "", $webEntryUid, SYS_LANG, $arrayData["WE_DESCRIPTION"]); } //Set WE_DATA $this->setWeData($webEntryUid); //Return if (!$this->formatFieldNameInUppercase) { $arrayData = array_change_key_case($arrayData, CASE_LOWER); } return $arrayData; } else { $msg = ""; foreach ($webEntry->getValidationFailures() as $validationFailure) { $msg = $msg . ($msg != "" ? "\n" : "") . $validationFailure->getMessage(); } throw new \Exception(\G::LoadTranslation("ID_REGISTRY_CANNOT_BE_UPDATED") . ($msg != "" ? "\n" . $msg : "")); } } catch (\Exception $e) { $cnn->rollback(); throw $e; } } catch (\Exception $e) { throw $e; } }
public function updateWebEntry($webEntryUid, $data) { try { $webEntry = \WebEntryPeer::retrieveByPK($webEntryUid); $webEntry->fromArray($data, \BasePeer::TYPE_FIELDNAME); $webEntry->save(); self::log("Update Web Entry Success!"); } catch (\Exception $e) { self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString()); throw $e; } }
/** * Delete WebEntry * * @param string $webEntryUid Unique id of WebEntry * @param string $webEntryTaskUid WebEntry, unique id of Task * * return void */ public function deleteWebEntry($webEntryUid, $webEntryTaskUid) { try { if ($webEntryTaskUid != "") { $obj = \TaskPeer::retrieveByPK($webEntryTaskUid); if (!is_null($obj)) { $task = new \Tasks(); $task->deleteTask($webEntryTaskUid); } } if ($webEntryUid != "") { $obj = \WebEntryPeer::retrieveByPK($webEntryUid); if (!is_null($obj)) { $this->webEntry->delete($webEntryUid); } } } catch (\Exception $e) { throw $e; } }