本文整理汇总了PHP中Status::getWarningsArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Status::getWarningsArray方法的具体用法?PHP Status::getWarningsArray怎么用?PHP Status::getWarningsArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Status
的用法示例。
在下文中一共展示了Status::getWarningsArray方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showStatusMessage
public function showStatusMessage(Status $status)
{
$warnings = array_merge($status->getWarningsArray(), $status->getErrorsArray());
if (count($warnings) !== 0) {
foreach ($warnings as $w) {
call_user_func_array(array($this, 'showMessage'), $w);
}
}
if (!$status->isOk()) {
echo "\n";
exit;
}
}
示例2: testGetStatusArrayWithNonObjectMessages
/**
* @dataProvider provideNonObjectMessages
* @covers Status::getStatusArray
*/
public function testGetStatusArrayWithNonObjectMessages($nonObjMsg)
{
$status = new Status();
if (!array_key_exists(1, $nonObjMsg)) {
$status->warning($nonObjMsg[0]);
} else {
$status->warning($nonObjMsg[0], $nonObjMsg[1]);
}
$array = $status->getWarningsArray();
// We use getWarningsArray to access getStatusArray
$this->assertEquals(1, count($array));
$this->assertEquals($nonObjMsg, $array[0]);
}
示例3: getErrorFromStatus
/**
* Get error (as code, string) from a Status object.
*
* @since 1.23
* @param Status $status
* @return array Array of code and error string
* @throws MWException
*/
public function getErrorFromStatus($status)
{
if ($status->isGood()) {
throw new MWException('Successful status passed to ApiBase::dieStatus');
}
$errors = $status->getErrorsArray();
if (!$errors) {
// No errors? Assume the warnings should be treated as errors
$errors = $status->getWarningsArray();
}
if (!$errors) {
// Still no errors? Punt
$errors = array(array('unknownerror-nocode'));
}
// Cannot use dieUsageMsg() because extensions might return custom
// error messages.
if ($errors[0] instanceof Message) {
$msg = $errors[0];
$code = $msg->getKey();
} else {
$code = array_shift($errors[0]);
$msg = wfMessage($code, $errors[0]);
}
if (isset(ApiBase::$messageMap[$code])) {
// Translate message to code, for backwards compatibility
$code = ApiBase::$messageMap[$code]['code'];
}
return array($code, $msg->inLanguage('en')->useDatabase(false)->plain());
}
示例4: errorText
/**
* Returns wikitext of status error message in content language
*
* @param Status $s
* @return String
*/
private function errorText(Status $s)
{
$errors = array_merge($s->getErrorsArray(), $s->getWarningsArray());
if (!count($errors)) {
return '';
}
$err = $errors[0];
$message = array_shift($err);
return wfMessage($message)->params($err)->inContentLanguage()->plain();
}
示例5: showStatusMessage
/**
* @param $status Status
*/
public function showStatusMessage(Status $status)
{
$errors = array_merge($status->getErrorsArray(), $status->getWarningsArray());
foreach ($errors as $error) {
call_user_func_array(array($this, 'showMessage'), $error);
}
}
示例6: testMergeWithOverwriteValue
/**
* @covers Status::merge
*/
public function testMergeWithOverwriteValue()
{
$status1 = new Status();
$status2 = new Status();
$message1 = $this->getMockMessage('warn1');
$message2 = $this->getMockMessage('error2');
$status1->warning($message1);
$status2->error($message2);
$status2->value = 'FooValue';
$status1->merge($status2, true);
$this->assertEquals(2, count($status1->getWarningsArray()) + count($status1->getErrorsArray()));
$this->assertEquals('FooValue', $status1->getValue());
}