* @param array $params
*
* @return bool
- * @throws Exception
+ * @throws CRM_Core_Exception
*/
public function createRelationships($relationshipTypeXML, &$params) {
/**
* @param $caseType
- * @param null $activityTypeName
+ * @param string|null $activityTypeName
*
* @return array|bool|mixed
- * @throws Exception
+ * @throws CRM_Core_Exception
*/
public function getMaxInstance($caseType, $activityTypeName = NULL) {
$xml = $this->retrieve($caseType);
if ($xml === FALSE) {
- throw new CRM_Core_Exception('Unable to read supplied XML File');
+ throw new CRM_Core_Exception('Unable to locate xml definition for case type ' . $caseType);
}
$activityInstances = $this->activityTypes($xml->ActivityTypes, TRUE);
* @param int $id
* ID of the Reminder to be deleted.
*
+ * @throws CRM_Core_Exception
*/
public static function del($id) {
if ($id) {
return;
}
}
- CRM_Core_Error::fatal(ts('Invalid value passed to delete function.'));
+ throw new CRM_Core_Exception(ts('Invalid value passed to delete function.'));
}
/**
$relTypeId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', 'Household Member of', 'id', 'name_a_b');
if (!$relTypeId) {
- CRM_Core_Error::fatal(ts("You seem to have deleted the relationship type 'Household Member of'"));
+ throw new CRM_Core_Exception(ts("You seem to have deleted the relationship type 'Household Member of'"));
}
$relParam = [
*
* @return array
* Array of $block objects.
+ * @throws CRM_Core_Exception
*/
public static function &getValues($blockName, $params) {
if (empty($params)) {
if (!isset($params['entity_table'])) {
$block->contact_id = $params['contact_id'];
if (!$block->contact_id) {
- CRM_Core_Error::fatal();
+ throw new CRM_Core_Exception('Invalid Contact ID parameter passed');
}
$blocks = self::retrieveBlock($block, $blockName);
}
* @param int $componentID
* The optional component ID (so componenets can share the same name space).
* @deprecated
+ * @throws CRM_Core_Exception
*/
public static function setItem(&$data, $group, $path, $componentID = NULL) {
CRM_Core_Error::deprecatedFunctionWarning(
// CRM-11234
$lock = Civi::lockManager()->acquire("cache.{$group}_{$path}._{$componentID}");
if (!$lock->isAcquired()) {
- CRM_Core_Error::fatal();
+ throw new CRM_Core_Exception('Cannot acquire database lock');
}
$table = self::getTableName();
*
* @return CRM_Core_BAO_CustomField
* The field object.
+ * @throws CRM_Core_Exception
*/
public static function getFieldObject($fieldID) {
$field = new CRM_Core_BAO_CustomField();
if (empty($fieldValues)) {
$field->id = $fieldID;
if (!$field->find(TRUE)) {
- CRM_Core_Error::fatal();
+ throw new CRM_Core_Exception('Cannot find Custom Field');
}
$fieldValues = [];
* FK to civicrm_custom_field.
* @param int $newGroupID
* FK to civicrm_custom_group.
+ *
+ * @throws CRM_Core_Exception
*/
public static function moveField($fieldID, $newGroupID) {
$validation = self::_moveFieldValidate($fieldID, $newGroupID);
if (TRUE !== $validation) {
- CRM_Core_Error::fatal(implode(' ', $validation));
+ throw new CRM_Core_Exception(implode(' ', $validation));
}
$field = new CRM_Core_DAO_CustomField();
$field->id = $fieldID;
*
* @return array
* fatal is fieldID does not exists, else array of tableName, columnName
- * @throws \Exception
+ * @throws \CRM_Core_Exception
*/
public static function getTableColumnGroup($fieldID, $force = FALSE) {
$cacheKey = "CRM_Core_DAO_CustomField_CustomGroup_TableColumn_{$fieldID}";
$dao = CRM_Core_DAO::executeQuery($query, $params);
if (!$dao->fetch()) {
- CRM_Core_Error::fatal();
+ throw new CRM_Core_Exception("Cannot find table and column information for Custom Field " . $fieldID);
}
$fieldValues = [$dao->table_name, $dao->column_name, $dao->id];
$cache->set($cacheKey, $fieldValues);
break;
default:
- CRM_Core_Error::fatal();
+ throw new CRM_Core_Exception('Invalid HTML Type');
}
$dao = CRM_Core_DAO::executeQuery($query, $queryParams);
}
case 'File':
if (!$field['file_id']) {
- CRM_Core_Error::fatal();
+ throw new CRM_Core_Exception('Missing parameter file_id');
}
// need to add/update civicrm_entity_file
return 'datetime';
default:
- CRM_Core_Error::fatal();
+ throw new CRM_Core_Exception('Invalid Field Type');
}
}
* Array of custom values for the entity with key=>value
* pairs specified as civicrm_custom_field.id => custom value.
* Empty array if no custom values found.
+ * @throws CRM_Core_Exception
*/
public static function &getEntityValues($entityID, $entityType = NULL, $fieldIDs = NULL, $formatMultiRecordField = FALSE, $DTparams = NULL) {
if (!$entityID) {
// adding this here since an empty contact id could have serious repurcussions
// like looping forever
- CRM_Core_Error::fatal('Please file an issue with the backtrace');
+ throw new CRM_Core_Exception('Please file an issue with the backtrace');
return NULL;
}
* @return int
* $dao->id discount id of the set which matches
* the date criteria
+ * @throws CRM_Core_Exception
*/
public static function findSet($entityID, $entityTable) {
if (empty($entityID) || empty($entityTable)) {
// adding this here, to trap errors if values are not sent
- CRM_Core_Error::fatal();
+ throw new CRM_Core_Exception('Invalid parameters passed to findSet function');
return NULL;
}
/**
* Delete a file attachment from an entity table / entity ID
- *
+ * @throws CRM_Core_Exception
*/
public static function deleteAttachment() {
$params = [];
$signer = new CRM_Utils_Signer(CRM_Core_Key::privateKey(), self::$_signableFields);
if (!$signer->validate($signature, $params)) {
- CRM_Core_Error::fatal('Request signature is invalid');
+ throw new CRM_Core_Exception('Request signature is invalid');
}
self::deleteEntityFile($params['entityTable'], $params['entityID'], NULL, $params['fileID']);
* ID of the job to be deleted.
*
* @return bool|null
+ * @throws CRM_Core_Exception
*/
public static function del($jobID) {
if (!$jobID) {
- CRM_Core_Error::fatal(ts('Invalid value passed to delete function.'));
+ throw new CRM_Core_Exception(ts('Invalid value passed to delete function.'));
}
$dao = new CRM_Core_DAO_Job();
// make sure serialized array will fit in the 'value' column
$attribute = CRM_Core_DAO::getAttribute('CRM_Core_BAO_LabelFormat', 'value');
if (strlen($this->value) > $attribute['maxlength']) {
- CRM_Core_Error::fatal(ts('Label Format does not fit in database.'));
+ throw new CRM_Core_Exception(ts('Label Format does not fit in database.'));
}
$this->save();
* Contact id.
* @param int $locationTypeId
* Id of the location to delete.
+ * @throws CRM_Core_Exception
*/
public static function deleteLocationBlocks($contactId, $locationTypeId) {
// ensure that contactId has a value
if (empty($contactId) ||
!CRM_Utils_Rule::positiveInteger($contactId)
) {
- CRM_Core_Error::fatal();
+ throw new CRM_Core_Exception('Incorrect contact id parameter passed to deleteLocationBlocks');
}
if (empty($locationTypeId) ||
*
* @return array
* formatted associated array of elements
+ * @throws CRM_Core_Exception
*/
public static function formattedFields(&$params, $row = FALSE) {
$fields = [];
foreach ($value as $k => $v) {
if (in_array($v[0], $types)) {
if ($contactType && $contactType != $v[0]) {
- CRM_Core_Error::fatal(ts("Cannot have two clauses with different types: %1, %2",
+ throw new CRM_Core_Exception(ts("Cannot have two clauses with different types: %1, %2",
[1 => $contactType, 2 => $v[0]]
));
}
*
* @return int
* Group ID (null if Group ID doesn't exist)
+ * @throws CRM_Core_Exception
*/
private static function _getGid() {
if (!self::$_gid) {
self::$_gid = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'paper_size', 'id', 'name');
if (!self::$_gid) {
- CRM_Core_Error::fatal(ts('Paper Size Option Group not found in database.'));
+ throw new CRM_Core_Exception(ts('Paper Size Option Group not found in database.'));
}
}
return self::$_gid;
* @param array $values associative array of name/value pairs
* @param int $id
* Id of the database record (null = new record).
+ * @throws CRM_Core_Exception
*/
public function savePaperSize(&$values, $id) {
// get the Option Group ID for Paper Sizes (create one if it doesn't exist)
// make sure serialized array will fit in the 'value' column
$attribute = CRM_Core_DAO::getAttribute('CRM_Core_BAO_PaperSize', 'value');
if (strlen($this->value) > $attribute['maxlength']) {
- CRM_Core_Error::fatal(ts('Paper Size does not fit in database.'));
+ throw new CRM_Core_Exception(ts('Paper Size does not fit in database.'));
}
$this->save();
*
* @param int $id
* ID of the Paper Size to be deleted.
- *
+ * @throws CRM_Core_Exception
*/
public static function del($id) {
if ($id) {
}
}
}
- CRM_Core_Error::fatal(ts('Invalid value passed to delete function.'));
+ throw new CRM_Core_Exception(ts('Invalid value passed to delete function.'));
}
}
*
* @return int
* Group ID (null if Group ID doesn't exist)
+ * @throws CRM_Core_Exception
*/
private static function _getGid() {
if (!self::$_gid) {
self::$_gid = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'pdf_format', 'id', 'name');
if (!self::$_gid) {
- CRM_Core_Error::fatal(ts('PDF Format Option Group not found in database.'));
+ throw new CRM_Core_Exception(ts('PDF Format Option Group not found in database.'));
}
}
return self::$_gid;
* @param array $values associative array of name/value pairs
* @param int $id
* Id of the database record (null = new record).
+ * @throws CRM_Core_Exception
*/
public function savePdfFormat(&$values, $id = NULL) {
// get the Option Group ID for PDF Page Formats (create one if it doesn't exist)
// make sure serialized array will fit in the 'value' column
$attribute = CRM_Core_DAO::getAttribute('CRM_Core_BAO_PdfFormat', 'value');
if (strlen($this->value) > $attribute['maxlength']) {
- CRM_Core_Error::fatal(ts('PDF Page Format does not fit in database.'));
+ throw new CRM_Core_Exception(ts('PDF Page Format does not fit in database.'));
}
$this->save();
*
* @param int $id
* ID of the PDF Page Format to be deleted.
- *
+ * @throws CRM_Core_Exception
*/
public static function del($id) {
if ($id) {
}
}
}
- CRM_Core_Error::fatal(ts('Invalid value passed to delete function.'));
+ throw new CRM_Core_Exception(ts('Invalid value passed to delete function.'));
}
}
* Id of the database record.
* @param bool $is_active
* Value we want to set the is_active field.
+ * @throws CRM_Core_Exception
*/
public static function setIsActive($id, $is_active) {
- CRM_Core_Error::fatal();
+ throw new CRM_Core_Exception('Cannot call setIsActive function');
}
/**
* Delete preference dates.
*
* @param int $id
+ * @throws CRM_Core_Exception
*/
public static function del($id) {
- CRM_Core_Error::fatal();
+ throw new CRM_Core_Exception('Cannot call del function');
}
/**
* Generate new DAOs and along with entries in civicrm_recurring_entity table.
*
* @return array
+ * @throws CRM_Core_Exception
*/
public function generateEntities() {
self::setStatus(self::RUNNING);
}
}
if (empty($findCriteria)) {
- CRM_Core_Error::fatal("Find criteria missing to generate form. Make sure entity_id and table is set.");
+ throw new CRM_Core_Exception("Find criteria missing to generate form. Make sure entity_id and table is set.");
}
$count = 0;
*
*
* @return object
+ * @throws new CRM_Core_Exception
*/
public static function copyCreateEntity($entityTable, $fromCriteria, $newParams, $createRecurringEntity = TRUE) {
$daoName = self::$_tableDAOMapper[$entityTable];
if (!$daoName) {
- CRM_Core_Error::fatal("DAO Mapper missing for $entityTable.");
+ throw new CRM_Core_Exception("DAO Mapper missing for $entityTable.");
}
$newObject = CRM_Core_DAO::copyGeneric($daoName, $fromCriteria, $newParams);
$updateDAO = CRM_Core_DAO::cascadeUpdate($daoName, $obj->id, $entityID, $skipData);
}
else {
- CRM_Core_Error::fatal("DAO Mapper missing for $entityTable.");
+ throw new CRM_Core_Exception("DAO Mapper missing for $entityTable.");
}
}
// done with processing. lets unset static var.
foreach (self::$_linkedEntitiesInfo as $linkedTable => $linfo) {
$daoName = self::$_tableDAOMapper[$linkedTable];
if (!$daoName) {
- CRM_Core_Error::fatal("DAO Mapper missing for $linkedTable.");
+ throw new CRM_Core_Exception("DAO Mapper missing for $linkedTable.");
}
$linkedDao = new $daoName();
* @param string $columnName
* @param $length
*
- * @throws Exception
+ * @throws CRM_Core_Exception
*/
public static function alterFieldLength($customFieldID, $tableName, $columnName, $length) {
// first update the custom field tables
CRM_Core_DAO::executeQuery($sql);
}
else {
- CRM_Core_Error::fatal(ts('Could Not Find Custom Field Details for %1, %2, %3',
+ throw new CRM_Core_Exception(ts('Could Not Find Custom Field Details for %1, %2, %3',
[
1 => $tableName,
2 => $columnName,
* @param array $params
*
* @return array
+ * @throws CRM_Core_Exception
*/
public static function create($params) {
$statusPreference = new CRM_Core_BAO_StatusPreference();
$params['ignore_severity'] = CRM_Utils_Check::severityMap($params['ignore_severity']);
}
if ($params['ignore_severity'] > 7) {
- CRM_Core_Error::fatal(ts('You can not pass a severity level higher than 7.'));
+ throw new CRM_Core_Exception(ts('You can not pass a severity level higher than 7.'));
}
// If severity is now blank, you have an invalid severity string.
if (is_null($params['ignore_severity'])) {
- CRM_Core_Error::fatal(ts('Invalid string passed as severity level.'));
+ throw new CRM_Core_Exception(ts('Invalid string passed as severity level.'));
}
// Check if this StatusPreference already exists.
if (!$domainEmailAddress || $domainEmailAddress == 'info@EXAMPLE.ORG') {
$fixUrl = CRM_Utils_System::url('civicrm/admin/domain', 'action=update&reset=1');
- CRM_Core_Error::fatal(ts('The site administrator needs to enter a valid \'FROM Email Address\' in <a href="%1">Administer CiviCRM » Communications » FROM Email Addresses</a>. The email address used may need to be a valid mail account with your email service provider.', [1 => $fixUrl]));
+ CRM_Core_Error::statusBounce(ts('The site administrator needs to enter a valid \'FROM Email Address\' in <a href="%1">Administer CiviCRM » Communications » FROM Email Addresses</a>. The email address used may need to be a valid mail account with your email service provider.', [1 => $fixUrl]));
}
foreach ($emailList as $emailTo) {
*
* @param $ctype
* @param bool $isLogin
+ *
+ * @throws CRM_Core_Exception
*/
public static function synchronize(&$user, $update, $uf, $ctype, $isLogin = FALSE) {
$userSystem = CRM_Core_Config::singleton()->userSystem;
$session = CRM_Core_Session::singleton();
if (!is_object($session)) {
- CRM_Core_Error::fatal('wow, session is not an object?');
+ throw new CRM_Core_Exception('wow, session is not an object?');
return;
}
* @param null $reset
*
* @return null|CRM_Core_BAO_WordReplacement
+ * @throws CRM_Core_Exception
*/
public static function getWordReplacement($reset = NULL) {
static $wordReplacement = NULL;
$wordReplacement = new CRM_Core_BAO_WordReplacement();
$wordReplacement->id = CRM_Core_Config::wordReplacementID();
if (!$wordReplacement->find(TRUE)) {
- CRM_Core_Error::fatal();
+ throw new CRM_Core_Exception('Unable to find word replacement');
}
}
return $wordReplacement;
$element = $this->addElement($type, $name, CRM_Utils_String::purifyHTML($label), $attributes, $extra);
if (HTML_QuickForm::isError($element)) {
- CRM_Core_Error::fatal(HTML_QuickForm::errorMessage($element));
+ CRM_Core_Error::statusBounce(HTML_QuickForm::errorMessage($element));
}
if ($inputType == 'color') {
$error = $this->addRule($name, ts('%1 is a required field.', [1 => $label]), 'required');
}
if (HTML_QuickForm::isError($error)) {
- CRM_Core_Error::fatal(HTML_QuickForm::errorMessage($element));
+ CRM_Core_Error::statusBounce(HTML_QuickForm::errorMessage($element));
}
}
$id = CRM_Utils_Request::retrieve('id', 'Int', $this);
$this->_structure = CRM_Core_I18n_SchemaStructure::columns();
if (!isset($this->_structure[$table][$field])) {
- CRM_Core_Error::fatal("$table.$field is not internationalized.");
+ CRM_Core_Error::statusBounce("$table.$field is not internationalized.");
}
$this->addElement('hidden', 'table', $table);
// validate table and field
if (!isset($this->_structure[$table][$field])) {
- CRM_Core_Error::fatal("$table.$field is not internationalized.");
+ CRM_Core_Error::statusBounce("$table.$field is not internationalized.");
}
$cols = [];
* An XML document defining a list of menu items.
* @param array $menu
* An alterable list of menu items.
+ *
+ * @throws CRM_Core_Exception
*/
public static function readXML($xml, &$menu) {
$config = CRM_Core_Config::singleton();
foreach ($xml->item as $item) {
if (!(string ) $item->path) {
CRM_Core_Error::debug('i', $item);
- CRM_Core_Error::fatal();
+ throw new CRM_Core_Exception('Unable to read XML file');
}
$path = (string ) $item->path;
$menu[$path] = array();
* @param array $menu
* @param string $path
*
- * @throws Exception
+ * @throws CRM_Core_Exception
*/
public static function fillMenuValues(&$menu, $path) {
$fieldsToPropagate = array(
return;
}
- $messages = array();
+ $messages = [];
foreach ($fieldsToPropagate as $field) {
if (!$fieldsPresent[$field]) {
$messages[] = ts("Could not find %1 in path tree",
- array(1 => $field)
+ [1 => $field]
);
}
}
- CRM_Core_Error::fatal("'$path': " . implode(', ', $messages));
+ throw new CRM_Core_Exception("'$path': " . implode(', ', $messages));
}
/**