Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] Remove fatal, fix some code comments #16928

Merged
merged 1 commit into from
Mar 31, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions CRM/Core/BAO/Domain.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public static function getDomain($reset = NULL) {
* @param bool $skipUsingCache
*
* @return null|string
*
* @throws \CRM_Core_Exception
*/
public static function version($skipUsingCache = FALSE) {
return CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Domain',
Expand All @@ -85,6 +87,8 @@ public static function version($skipUsingCache = FALSE) {
*
* @return array
* Location::getValues
*
* @throws \CRM_Core_Exception
*/
public function &getLocationValues() {
if ($this->_location == NULL) {
Expand All @@ -107,8 +111,7 @@ public function &getLocationValues() {
* @param array $params
* @param int $id
*
* @return array
* domain
* @return CRM_Core_DAO_Domain
*/
public static function edit(&$params, &$id) {
CRM_Utils_Hook::pre('edit', 'Domain', CRM_Utils_Array::value('id', $params), $params);
Expand All @@ -125,8 +128,7 @@ public static function edit(&$params, &$id) {
*
* @param array $params
*
* @return array
* domain
* @return CRM_Core_DAO_Domain
*/
public static function create($params) {
$hook = empty($params['id']) ? 'create' : 'edit';
Expand All @@ -146,7 +148,7 @@ public static function multipleDomains() {

$numberDomains = $session->get('numberDomains');
if (!$numberDomains) {
$query = "SELECT count(*) from civicrm_domain";
$query = 'SELECT count(*) from civicrm_domain';
$numberDomains = CRM_Core_DAO::singleValueQuery($query);
$session->set('numberDomains', $numberDomains);
}
Expand All @@ -156,9 +158,11 @@ public static function multipleDomains() {
/**
* @param bool $skipFatal
* @param bool $returnString
*
* @return array
* name & email for domain
* @throws Exception
*
* @throws \CRM_Core_Exception
*/
public static function getNameAndEmail($skipFatal = FALSE, $returnString = FALSE) {
$fromEmailAddress = CRM_Core_OptionGroup::values('from_email_address', NULL, NULL, NULL, ' AND is_default = 1');
Expand All @@ -185,13 +189,15 @@ public static function getNameAndEmail($skipFatal = FALSE, $returnString = FALSE
);
$status = ts("There is no valid default from email address configured for the domain. You can configure here <a href='%1'>Configure From Email Address.</a>", [1 => $url]);

CRM_Core_Error::fatal($status);
throw new CRM_Core_Exception($status);
}

/**
* @param int $contactID
*
* @return bool|null|object|string
*
* @throws \CRM_Core_Exception
*/
public static function addContactToDomainGroup($contactID) {
$groupID = self::getGroupId();
Expand All @@ -207,6 +213,8 @@ public static function addContactToDomainGroup($contactID) {

/**
* @return bool|null|object|string
*
* @throws \CRM_Core_Exception
*/
public static function getGroupId() {
static $groupID = NULL;
Expand Down Expand Up @@ -237,6 +245,8 @@ public static function getGroupId() {
* @param int $groupId
*
* @return bool
*
* @throws \CRM_Core_Exception
*/
public static function isDomainGroup($groupId) {
$domainGroupID = self::getGroupId();
Expand All @@ -245,6 +255,8 @@ public static function isDomainGroup($groupId) {

/**
* @return array
*
* @throws \CRM_Core_Exception
*/
public static function getChildGroupIds() {
$domainGroupID = self::getGroupId();
Expand All @@ -261,6 +273,8 @@ public static function getChildGroupIds() {
* Retrieve a list of contact-ids that belongs to current domain/site.
*
* @return array
*
* @throws \CRM_Core_Exception
*/
public static function getContactList() {
$siteGroups = CRM_Core_BAO_Domain::getChildGroupIds();
Expand All @@ -285,6 +299,8 @@ public static function getContactList() {
* CRM-20308 & CRM-19657
* Return domain information / user information for the usage in receipts
* Try default from address then fall back to using logged in user details
*
* @throws \CiviCRM_API3_Exception
*/
public static function getDefaultReceiptFrom() {
$domain = civicrm_api3('domain', 'getsingle', ['id' => CRM_Core_Config::domainID()]);
Expand Down