mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-24 16:04:35 +00:00
Remove EchoNotificationFormatter::requiredParameters
Instead, have subclasses implement checking required parameters manually. The only subclass that was using this was EchoBasicFormatter and has been updated. Change-Id: I23e2fa7044e0d59125530024f8c6c35516d3b90b
This commit is contained in:
parent
1a74ec545b
commit
1561725130
|
@ -46,14 +46,6 @@ class EchoBasicFormatter extends EchoNotificationFormatter {
|
|||
*/
|
||||
protected $language;
|
||||
|
||||
/**
|
||||
* Required parameters
|
||||
* @param array
|
||||
*/
|
||||
protected $requiredParameters = array (
|
||||
'title-message'
|
||||
);
|
||||
|
||||
/**
|
||||
* Data for constructing bundle message, data in this array
|
||||
* should be used in function processParams()
|
||||
|
@ -75,6 +67,11 @@ class EchoBasicFormatter extends EchoNotificationFormatter {
|
|||
public function __construct( $params ) {
|
||||
parent::__construct( $params );
|
||||
|
||||
if ( !isset( $params['title-message'] ) ) {
|
||||
// Required, no default value set
|
||||
throw new InvalidArgumentException( "'title-message' parameter not set" );
|
||||
}
|
||||
|
||||
// Set up default params if any are missing
|
||||
$params = $this->setDefaultParams( $params );
|
||||
|
||||
|
|
|
@ -37,11 +37,6 @@ abstract class EchoNotificationFormatter {
|
|||
*/
|
||||
protected $parameters;
|
||||
|
||||
/**
|
||||
* List of parameters that must exist in $this->$parameters
|
||||
*/
|
||||
protected $requiredParameters = array();
|
||||
|
||||
/**
|
||||
* Creates an instance of the given class with the given parameters.
|
||||
* @param $parameters array Associative array of parameters
|
||||
|
@ -49,16 +44,6 @@ abstract class EchoNotificationFormatter {
|
|||
*/
|
||||
public function __construct( array $parameters ) {
|
||||
$this->parameters = $parameters;
|
||||
|
||||
$missingParameters = array_diff( $this->requiredParameters, array_keys( $parameters ) );
|
||||
|
||||
if ( $missingParameters ) {
|
||||
throw new MWException(
|
||||
"Missing required parameters for " .
|
||||
get_class( $this ) . ":" .
|
||||
implode( " ", $missingParameters )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue