本文整理汇总了PHP中Status::wrap方法的典型用法代码示例。如果您正苦于以下问题:PHP Status::wrap方法的具体用法?PHP Status::wrap怎么用?PHP Status::wrap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Status
的用法示例。
在下文中一共展示了Status::wrap方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute()
{
if (!$this->hasAnyRoutes()) {
$this->dieUsage('No password reset routes are available.', 'moduledisabled');
}
$params = $this->extractRequestParams() + ['user' => null, 'email' => null];
$this->requireOnlyOneParameter($params, 'user', 'email');
$passwordReset = new PasswordReset($this->getConfig(), AuthManager::singleton());
$status = $passwordReset->isAllowed($this->getUser(), $params['capture']);
if (!$status->isOK()) {
$this->dieStatus(Status::wrap($status));
}
$status = $passwordReset->execute($this->getUser(), $params['user'], $params['email'], $params['capture']);
if (!$status->isOK()) {
$status->value = null;
$this->dieStatus(Status::wrap($status));
}
$result = $this->getResult();
$result->addValue(['resetpassword'], 'status', 'success');
if ($params['capture']) {
$passwords = $status->getValue() ?: [];
ApiResult::setArrayType($passwords, 'kvp', 'user');
ApiResult::setIndexedTagName($passwords, 'p');
$result->addValue(['resetpassword'], 'passwords', $passwords);
}
}
示例2: getByStatus
public static function getByStatus($status)
{
global $db;
$sql = "SELECT * FROM statuses WHERE LOWER(status)=?";
$values = array(strtolower($status));
$stat = $db->qwv($sql, $values);
return Status::wrap($stat);
}
示例3: showSuccessPage
/**
* Show the success page.
*
* @param string $type Condition of return to; see `executeReturnTo`
* @param string|Message $title Page's title
* @param string $msgname
* @param string $injected_html
* @param StatusValue|null $extraMessages
*/
protected function showSuccessPage($type, $title, $msgname, $injected_html, $extraMessages)
{
$out = $this->getOutput();
$out->setPageTitle($title);
if ($msgname) {
$out->addWikiMsg($msgname, wfEscapeWikiText($this->getUser()->getName()));
}
if ($extraMessages) {
$extraMessages = Status::wrap($extraMessages);
$out->addWikiText($extraMessages->getWikiText());
}
$out->addHTML($injected_html);
$helper = new LoginHelper($this->getContext());
$helper->showReturnToPage($type, $this->mReturnTo, $this->mReturnToQuery, $this->mStickHTTPS);
}
示例4: displayForm
/**
* Display the form.
* @param false|Status|StatusValue $status A form submit status, as in HTMLForm::trySubmit()
*/
protected function displayForm($status)
{
if ($status instanceof StatusValue) {
$status = Status::wrap($status);
}
$form = $this->getAuthForm($this->authRequests, $this->authAction);
$form->prepareForm()->displayForm($status);
}
示例5: provideAllowsAuthenticationDataChange
public static function provideAllowsAuthenticationDataChange()
{
$ignored = \Status::newGood('ignored');
$ignored->warning('authmanager-change-not-supported');
$okFromPrimary = StatusValue::newGood();
$okFromPrimary->warning('warning-from-primary');
$okFromSecondary = StatusValue::newGood();
$okFromSecondary->warning('warning-from-secondary');
return [[StatusValue::newGood(), StatusValue::newGood(), \Status::newGood()], [StatusValue::newGood(), StatusValue::newGood('ignore'), \Status::newGood()], [StatusValue::newGood('ignored'), StatusValue::newGood(), \Status::newGood()], [StatusValue::newGood('ignored'), StatusValue::newGood('ignored'), $ignored], [StatusValue::newFatal('fail from primary'), StatusValue::newGood(), \Status::newFatal('fail from primary')], [$okFromPrimary, StatusValue::newGood(), \Status::wrap($okFromPrimary)], [StatusValue::newGood(), StatusValue::newFatal('fail from secondary'), \Status::newFatal('fail from secondary')], [StatusValue::newGood(), $okFromSecondary, \Status::wrap($okFromSecondary)]];
}
示例6: provideProviderAllowsAuthenticationDataChange
public static function provideProviderAllowsAuthenticationDataChange()
{
$err = \StatusValue::newGood();
$err->error('arbitrary-warning');
return [[AuthenticationRequest::class, 'UTSysop', \Status::newGood(), \StatusValue::newGood('ignored'), \StatusValue::newGood('ignored')], [PasswordAuthenticationRequest::class, 'UTSysop', \Status::newGood(), \StatusValue::newGood('ignored'), \StatusValue::newGood('ignored')], [TemporaryPasswordAuthenticationRequest::class, 'UTSysop', \Status::newGood(), \StatusValue::newGood(), \StatusValue::newGood()], [TemporaryPasswordAuthenticationRequest::class, 'uTSysop', \Status::newGood(), \StatusValue::newGood(), \StatusValue::newGood()], [TemporaryPasswordAuthenticationRequest::class, 'UTSysop', \Status::wrap($err), \StatusValue::newGood(), $err], [TemporaryPasswordAuthenticationRequest::class, 'UTSysop', \Status::newFatal('arbitrary-error'), \StatusValue::newGood(), \StatusValue::newFatal('arbitrary-error')], [TemporaryPasswordAuthenticationRequest::class, 'DoesNotExist', \Status::newGood(), \StatusValue::newGood(), \StatusValue::newGood('ignored')], [TemporaryPasswordAuthenticationRequest::class, '<invalid>', \Status::newGood(), \StatusValue::newGood(), \StatusValue::newGood('ignored')]];
}
示例7: onSubmit
/**
* Process the form. At this point we know that the user passes all the criteria in
* userCanExecute(), and if the data array contains 'Username', etc, then Username
* resets are allowed.
* @param array $data
* @throws MWException
* @throws ThrottledError|PermissionsError
* @return Status
*/
public function onSubmit(array $data)
{
if (isset($data['Capture']) && !$this->getUser()->isAllowed('passwordreset')) {
// The user knows they don't have the passwordreset permission,
// but they tried to spoof the form. That's naughty
throw new PermissionsError('passwordreset');
}
$username = isset($data['Username']) ? $data['Username'] : null;
$email = isset($data['Email']) ? $data['Email'] : null;
$capture = !empty($data['Capture']);
$this->method = $username ? 'username' : 'email';
$this->result = Status::wrap($this->passwordReset->execute($this->getUser(), $username, $email, $capture));
if ($capture && $this->result->isOK()) {
$this->passwords = $this->result->getValue();
}
if ($this->result->hasMessage('actionthrottledtext')) {
throw new ThrottledError();
}
return $this->result;
}