use correct namespace
This commit is contained in:
parent
1875861735
commit
b0d5bdefa5
5 changed files with 6 additions and 8 deletions
|
@ -1,48 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace CRM\Twingle\Exceptions;
|
||||
|
||||
use CRM_Twingle_ExtensionUtil as E;
|
||||
|
||||
/**
|
||||
* A simple custom exception class that indicates a problem within a class
|
||||
* of the Twingle API extension.
|
||||
*/
|
||||
class BaseException extends \Exception {
|
||||
|
||||
/**
|
||||
* @var int|string
|
||||
*/
|
||||
protected $code;
|
||||
protected string $log_message;
|
||||
|
||||
/**
|
||||
* BaseException Constructor
|
||||
* @param string $message
|
||||
* Error message
|
||||
* @param string $error_code
|
||||
* A meaningful error code
|
||||
*/
|
||||
public function __construct(string $message = '', string $error_code = '') {
|
||||
parent::__construct($message, 1);
|
||||
$this->log_message = !empty($message) ? E::LONG_NAME . ': ' . $message : '';
|
||||
$this->code = $error_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the error message, but with the extension name prefixed.
|
||||
* @return string
|
||||
*/
|
||||
public function getLogMessage() {
|
||||
return $this->log_message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the error code.
|
||||
* @return string
|
||||
*/
|
||||
public function getErrorCode() {
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace CRM\Twingle\Exceptions;
|
||||
|
||||
/**
|
||||
* A simple custom exception that indicates a problem within the
|
||||
* CRM_Twingle_Profile class
|
||||
*/
|
||||
class ProfileException extends BaseException {
|
||||
|
||||
public const ERROR_CODE_PROFILE_NOT_FOUND = 'profile_not_found';
|
||||
public const ERROR_CODE_DEFAULT_PROFILE_NOT_FOUND = 'default_profile_not_found';
|
||||
public const ERROR_CODE_COULD_NOT_SAVE_PROFILE = 'could_not_save_profile';
|
||||
public const ERROR_CODE_COULD_NOT_RESET_PROFILE = 'could_not_reset_profile';
|
||||
public const ERROR_CODE_COULD_NOT_DELETE_PROFILE = 'could_not_delete_profile';
|
||||
public const ERROR_CODE_UNKNOWN_PROFILE_ATTRIBUTE = 'unknown_profile_attribute';
|
||||
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace CRM\Twingle\Exceptions;
|
||||
|
||||
/**
|
||||
* A simple custom error indicating a problem with the validation of the
|
||||
* CRM_Twingle_Profile
|
||||
*/
|
||||
class ProfileValidationError extends BaseException {
|
||||
|
||||
private string $affected_field_name;
|
||||
public const ERROR_CODE_PROFILE_VALIDATION_FAILED = 'profile_validation_failed';
|
||||
public const ERROR_CODE_PROFILE_VALIDATION_WARNING = 'profile_validation_warning';
|
||||
|
||||
/**
|
||||
* ProfileValidationError Constructor
|
||||
* @param string $affected_field_name
|
||||
* The name of the profile field which caused the exception
|
||||
* @param string $message
|
||||
* Error message
|
||||
* @param string $error_code
|
||||
* A meaningful error code
|
||||
*/
|
||||
public function __construct(string $affected_field_name, string $message = '', string $error_code = '') {
|
||||
parent::__construct($message, $error_code);
|
||||
$this->affected_field_name = $affected_field_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the profile field that caused the exception.
|
||||
* @return string
|
||||
*/
|
||||
public function getAffectedFieldName() {
|
||||
return $this->affected_field_name;
|
||||
}
|
||||
|
||||
}
|
|
@ -16,8 +16,7 @@
|
|||
declare(strict_types = 1);
|
||||
|
||||
use CRM_Twingle_ExtensionUtil as E;
|
||||
use CRM\Twingle\Exceptions\ProfileException as ProfileException;
|
||||
use CRM\Twingle\Exceptions\ProfileValidationError as ProfileValidationError;
|
||||
use Civi\Twingle\Exceptions\ProfileException as ProfileException;
|
||||
|
||||
/**
|
||||
* Form controller class
|
||||
|
@ -560,7 +559,7 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form {
|
|||
E::ts('Could not parse custom field mapping.')
|
||||
);
|
||||
}
|
||||
list($twingle_field_name, $custom_field_name) = $custom_field_map;
|
||||
[$twingle_field_name, $custom_field_name] = $custom_field_map;
|
||||
$custom_field_id = substr($custom_field_name, strlen('custom_'));
|
||||
|
||||
// Check for custom field existence
|
||||
|
|
|
@ -16,8 +16,7 @@
|
|||
declare(strict_types = 1);
|
||||
|
||||
use CRM_Twingle_ExtensionUtil as E;
|
||||
use CRM\Twingle\Exceptions\ProfileException as ProfileException;
|
||||
use CRM\Twingle\Exceptions\ProfileValidationError as ProfileValidationError;
|
||||
use Civi\Twingle\Exceptions\ProfileException as ProfileException;
|
||||
|
||||
/**
|
||||
* Profiles define how incoming submissions from the Twingle API are
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue