return new self( $sv );
}
+ /**
+ * Splits this Status object into two new Status objects, one which contains only
+ * the error messages, and one that contains the warnings, only. The returned array is
+ * defined as:
+ * array(
+ * 0 => object(Status) # the Status with error messages, only
+ * 1 => object(Status) # The Status with warning messages, only
+ * )
+ *
+ * @return array
+ */
+ public function splitByErrorType() {
+ list( $errorsOnlyStatusValue, $warningsOnlyStatusValue ) = $this->sv->splitByErrorType();
+ $errorsOnlyStatus = new Status( $errorsOnlyStatusValue );
+ $warningsOnlyStatus = new Status( $warningsOnlyStatusValue );
+ $errorsOnlyStatus->cleanCallback = $warningsOnlyStatus->cleanCallback = $this->cleanCallback;
+
+ return [ $errorsOnlyStatus, $warningsOnlyStatus ];
+ }
+
/**
* Change operation result
*
/**
* Returns the wrapped StatusValue object
* @return StatusValue
+ * @since 1.27
*/
public function getStatusValue() {
return $this->sv;
}
/**
- * Get the error list as a Message object
+ * Get a bullet list of the errors as a Message object.
*
- * @param string|string[] $shortContext A short enclosing context message name (or an array of
- * message names), to be used when there is a single error.
- * @param string|string[] $longContext A long enclosing context message name (or an array of
- * message names), for a list.
+ * $shortContext and $longContext can be used to wrap the error list in some text.
+ * $shortContext will be preferred when there is a single error; $longContext will be
+ * preferred when there are multiple ones. In either case, $1 will be replaced with
+ * the list of errors.
+ *
+ * $shortContext is assumed to use $1 as an inline parameter: if there is a single item,
+ * it will not be made into a list; if there are multiple items, newlines will be inserted
+ * around the list.
+ * $longContext is assumed to use $1 as a standalone parameter; it will always receive a list.
+ *
+ * If both parameters are missing, and there is only one error, no bullet will be added.
+ *
+ * @param string|string[] $shortContext A message name or an array of message names.
+ * @param string|string[] $longContext A message name or an array of message names.
* @param string|Language $lang Language to use for processing messages
* @return Message
*/
$msgs = $this->getErrorMessageArray( $rawErrors, $lang );
$msgCount = count( $msgs );
- if ( $shortContext ) {
- $msgCount++;
- }
-
$s = new RawMessage( '* $' . implode( "\n* \$", range( 1, $msgCount ) ) );
$s->params( $msgs )->parse();
/**
* Return the message for a single error.
+ *
* @param mixed $error With an array & two values keyed by
* 'message' and 'params', use those keys-value pairs.
* Otherwise, if its an array, just use the first value as the
*
* @return array A list in which each entry is an array with a message key as its first element.
* The remaining array elements are the message parameters.
- * @deprecated 1.25
+ * @deprecated since 1.25
*/
public function getErrorsArray() {
return $this->getStatusArray( 'error' );
*
* @return array A list in which each entry is an array with a message key as its first element.
* The remaining array elements are the message parameters.
- * @deprecated 1.25
+ * @deprecated since 1.25
*/
public function getWarningsArray() {
return $this->getStatusArray( 'warning' );