当前位置: 首页>>代码示例>>PHP>>正文


PHP Status::getErrorsByType方法代码示例

本文整理汇总了PHP中Status::getErrorsByType方法的典型用法代码示例。如果您正苦于以下问题:PHP Status::getErrorsByType方法的具体用法?PHP Status::getErrorsByType怎么用?PHP Status::getErrorsByType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Status的用法示例。


在下文中一共展示了Status::getErrorsByType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getStatusError

 /**
  * Get error message key and parameters from status
  *
  * @param \Status $status
  * @return array of error message key, and message parameters as an array
  * @throws Exception if called on an "OK" Status
  */
 public function getStatusError(\Status $status)
 {
     if ($status->isOK()) {
         throw new \Exception('Status contains no errors');
     }
     $errors = $status->getErrorsByType('error');
     if (!empty($errors[0]['message'])) {
         $message = $errors[0]['message'];
         $params = $errors[0]['params'];
     } else {
         $message = 'fbconnect-error';
         $params = [];
     }
     return [$message, $params];
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:22,代码来源:FacebookClientFactory.php

示例2: testGetErrorsByType

 /**
  * @covers Status::getErrorsByType
  */
 public function testGetErrorsByType()
 {
     $status = new Status();
     $warning = new Message('warning111');
     $error = new Message('error111');
     $status->warning($warning);
     $status->error($error);
     $warnings = $status->getErrorsByType('warning');
     $errors = $status->getErrorsByType('error');
     $this->assertCount(1, $warnings);
     $this->assertCount(1, $errors);
     $this->assertEquals($warning, $warnings[0]['message']);
     $this->assertEquals($error, $errors[0]['message']);
 }
开发者ID:Habatchii,项目名称:wikibase-for-mediawiki,代码行数:17,代码来源:StatusTest.php

示例3: convertStatusToArray

 /**
  * Converts a Status object to an array suitable for addValue
  * @param Status $status
  * @param string $errorType
  * @return array
  */
 public function convertStatusToArray($status, $errorType = 'error')
 {
     if ($status->isGood()) {
         return array();
     }
     $result = array();
     foreach ($status->getErrorsByType($errorType) as $error) {
         $this->setIndexedTagName($error['params'], 'param');
         $result[] = $error;
     }
     $this->setIndexedTagName($result, $errorType);
     return $result;
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:19,代码来源:ApiResult.php

示例4: arrayFromStatus

 public function arrayFromStatus(Status $status, $type = 'error', $format = null)
 {
     if ($status->isGood() || !$status->errors) {
         return [];
     }
     $result = [];
     foreach ($status->getErrorsByType($type) as $error) {
         if ($error['message'] instanceof Message) {
             $error = ['message' => $error['message']->getKey(), 'params' => $error['message']->getParams()] + $error;
         }
         ApiResult::setIndexedTagName($error['params'], 'param');
         $result[] = $error;
     }
     ApiResult::setIndexedTagName($result, $type);
     return $result;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:16,代码来源:ApiErrorFormatter.php

示例5: getErrors

 /**
  * @param string|array|Status $err
  * @return string
  */
 function getErrors($err)
 {
     if (!$err) {
         $errors = array();
     } elseif ($err instanceof Status) {
         if ($err->isOK()) {
             $errors = array();
         } else {
             $errors = $err->getErrorsByType('error');
             foreach ($errors as &$error) {
                 // Input:  array( 'message' => 'foo', 'errors' => array( 'a', 'b', 'c' ) )
                 // Output: array( 'foo', 'a', 'b', 'c' )
                 $error = array_merge(array($error['message']), $error['params']);
             }
         }
     } else {
         $errors = $err;
         if (!is_array($errors)) {
             $errors = array($errors);
         }
     }
     foreach ($errors as &$error) {
         if (is_array($error)) {
             $msg = array_shift($error);
         } else {
             $msg = $error;
             $error = array();
         }
         // if the error is already a message object, don't use it as a message key
         if (!$msg instanceof Message) {
             $error = $this->msg($msg, $error)->parse();
         } else {
             $error = $msg->parse();
         }
         $error = new OOUI\HtmlSnippet($error);
     }
     // Used in getBody()
     $this->oouiErrors = $errors;
     return '';
 }
开发者ID:Acidburn0zzz,项目名称:mediawiki,代码行数:44,代码来源:OOUIHTMLForm.php

示例6: getErrorFromStatus

 /**
  * Get error (as code, string) from a Status object.
  *
  * @since 1.23
  * @param Status $status
  * @param array|null &$extraData Set if extra data from IApiMessage is available (since 1.27)
  * @return array Array of code and error string
  * @throws MWException
  */
 public function getErrorFromStatus($status, &$extraData = null)
 {
     if ($status->isGood()) {
         throw new MWException('Successful status passed to ApiBase::dieStatus');
     }
     $errors = $status->getErrorsByType('error');
     if (!$errors) {
         // No errors? Assume the warnings should be treated as errors
         $errors = $status->getErrorsByType('warning');
     }
     if (!$errors) {
         // Still no errors? Punt
         $errors = [['message' => 'unknownerror-nocode', 'params' => []]];
     }
     // Cannot use dieUsageMsg() because extensions might return custom
     // error messages.
     if ($errors[0]['message'] instanceof Message) {
         $msg = $errors[0]['message'];
         if ($msg instanceof IApiMessage) {
             $extraData = $msg->getApiData();
             $code = $msg->getApiCode();
         } else {
             $code = $msg->getKey();
         }
     } else {
         $code = $errors[0]['message'];
         $msg = wfMessage($code, $errors[0]['params']);
     }
     if (isset(ApiBase::$messageMap[$code])) {
         // Translate message to code, for backwards compatibility
         $code = ApiBase::$messageMap[$code]['code'];
     }
     return [$code, $msg->inLanguage('en')->useDatabase(false)->plain()];
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:43,代码来源:ApiBase.php

示例7: getErrorsOrWarnings

 /**
  * @param string|array|Status $elements
  * @param string $elementsType
  * @return string
  */
 function getErrorsOrWarnings($elements, $elementsType)
 {
     if (!in_array($elementsType, ['error', 'warning'])) {
         throw new DomainException($elementsType . ' is not a valid type.');
     }
     if (!$elements) {
         $errors = [];
     } elseif ($elements instanceof Status) {
         if ($elements->isGood()) {
             $errors = [];
         } else {
             $errors = $elements->getErrorsByType($elementsType);
             foreach ($errors as &$error) {
                 // Input:  [ 'message' => 'foo', 'errors' => [ 'a', 'b', 'c' ] ]
                 // Output: [ 'foo', 'a', 'b', 'c' ]
                 $error = array_merge([$error['message']], $error['params']);
             }
         }
     } elseif ($elementsType === 'errors') {
         $errors = $elements;
         if (!is_array($errors)) {
             $errors = [$errors];
         }
     } else {
         $errors = [];
     }
     foreach ($errors as &$error) {
         $error = $this->getMessage($error)->parse();
         $error = new OOUI\HtmlSnippet($error);
     }
     // Used in getBody()
     if ($elementsType === 'error') {
         $this->oouiErrors = $errors;
     } else {
         $this->oouiWarnings = $errors;
     }
     return '';
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:43,代码来源:OOUIHTMLForm.php

示例8: getErrors

 /**
  * @param string|array|Status $err
  * @return string
  */
 function getErrors($err)
 {
     if (!$err) {
         $errors = [];
     } elseif ($err instanceof Status) {
         if ($err->isOK()) {
             $errors = [];
         } else {
             $errors = $err->getErrorsByType('error');
             foreach ($errors as &$error) {
                 // Input:  array( 'message' => 'foo', 'errors' => array( 'a', 'b', 'c' ) )
                 // Output: array( 'foo', 'a', 'b', 'c' )
                 $error = array_merge([$error['message']], $error['params']);
             }
         }
     } else {
         $errors = $err;
         if (!is_array($errors)) {
             $errors = [$errors];
         }
     }
     foreach ($errors as &$error) {
         $error = $this->getMessage($error)->parse();
         $error = new OOUI\HtmlSnippet($error);
     }
     // Used in getBody()
     $this->oouiErrors = $errors;
     return '';
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:33,代码来源:OOUIHTMLForm.php


注:本文中的Status::getErrorsByType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。