本文整理汇总了PHP中SS_HTTPResponse::setStatusDescription方法的典型用法代码示例。如果您正苦于以下问题:PHP SS_HTTPResponse::setStatusDescription方法的具体用法?PHP SS_HTTPResponse::setStatusDescription怎么用?PHP SS_HTTPResponse::setStatusDescription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SS_HTTPResponse
的用法示例。
在下文中一共展示了SS_HTTPResponse::setStatusDescription方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doSend
public function doSend($data, $form)
{
try {
$this->record->doSend();
} catch (PushException $ex) {
return new SS_HTTPResponse($this->ItemEditForm()->forAjaxTemplate(), 400, $ex->getMessage());
}
$response = new SS_HTTPResponse($this->ItemEditForm()->forAjaxTemplate());
$response->setStatusDescription(_t('Push.PUSHSENT', 'The push notification has been sent'));
return $response;
}
开发者ID:silverstripe-australia,项目名称:silverstripe-push,代码行数:11,代码来源:PushNotificationsAdminItemRequest.php
示例2: remove
/**
* Action to handle removing a single file from the db relation
*
* @param SS_HTTPRequest $request
* @return SS_HTTPResponse
*/
public function remove(SS_HTTPRequest $request)
{
// Check form field state
if ($this->parent->isDisabled() || $this->parent->isReadonly()) {
return $this->httpError(403);
}
// Protect against CSRF on destructive action
$token = $this->parent->getForm()->getSecurityToken();
if (!$token->checkRequest($request)) {
return $this->httpError(400);
}
$response = new SS_HTTPResponse();
$response->setStatusCode(500);
$fieldName = $this->parent->getName();
$record = $this->parent->getRecord();
$id = $this->getItem()->ID;
if ($id && $record && $record->exists()) {
if (($record->has_many($fieldName) || $record->many_many($fieldName)) && ($file = $record->{$fieldName}()->byID($id))) {
$record->{$fieldName}()->remove($file);
$response->setStatusCode(200);
} elseif ($record->has_one($fieldName) && $record->{$fieldName . 'ID'} == $id) {
$record->{$fieldName . 'ID'} = 0;
$record->write();
$response->setStatusCode(200);
}
}
if ($response->getStatusCode() != 200) {
$response->setStatusDescription(_t('UploadField.REMOVEERROR', 'Error removing file'));
}
return $response;
}