本文整理汇总了PHP中AphrontRequest::getPassthroughRequestData方法的典型用法代码示例。如果您正苦于以下问题:PHP AphrontRequest::getPassthroughRequestData方法的具体用法?PHP AphrontRequest::getPassthroughRequestData怎么用?PHP AphrontRequest::getPassthroughRequestData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AphrontRequest
的用法示例。
在下文中一共展示了AphrontRequest::getPassthroughRequestData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$project_id = $request->getURIData('projectID');
$project = id(new PhabricatorProjectQuery())->setViewer($viewer)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->withIDs(array($project_id))->executeOne();
if (!$project) {
return new Aphront404Response();
}
$this->setProject($project);
$column = id(new PhabricatorProjectColumnQuery())->setViewer($viewer)->withIDs(array($id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
if (!$column) {
return new Aphront404Response();
}
$column_phid = $column->getPHID();
$view_uri = $this->getApplicationURI('/board/' . $project_id . '/');
$view_uri = new PhutilURI($view_uri);
foreach ($request->getPassthroughRequestData() as $key => $value) {
$view_uri->setQueryParam($key, $value);
}
if ($column->isDefaultColumn()) {
return $this->newDialog()->setTitle(pht('Can Not Hide Default Column'))->appendParagraph(pht('You can not hide the default/backlog column on a board.'))->addCancelButton($view_uri, pht('Okay'));
}
if ($request->isFormPost()) {
if ($column->isHidden()) {
$new_status = PhabricatorProjectColumn::STATUS_ACTIVE;
} else {
$new_status = PhabricatorProjectColumn::STATUS_HIDDEN;
}
$type_status = PhabricatorProjectColumnTransaction::TYPE_STATUS;
$xactions = array(id(new PhabricatorProjectColumnTransaction())->setTransactionType($type_status)->setNewValue($new_status));
$editor = id(new PhabricatorProjectColumnTransactionEditor())->setActor($viewer)->setContinueOnNoEffect(true)->setContentSourceFromRequest($request)->applyTransactions($column, $xactions);
return id(new AphrontRedirectResponse())->setURI($view_uri);
}
if ($column->isHidden()) {
$title = pht('Show Column');
} else {
$title = pht('Hide Column');
}
if ($column->isHidden()) {
$body = pht('Are you sure you want to show this column?');
} else {
$body = pht('Are you sure you want to hide this column? It will no longer ' . 'appear on the workboard.');
}
$dialog = $this->newDialog()->setWidth(AphrontDialogView::WIDTH_FORM)->setTitle($title)->appendChild($body)->setDisableWorkflowOnCancel(true)->addCancelButton($view_uri)->addSubmitButton($title);
foreach ($request->getPassthroughRequestData() as $key => $value) {
$dialog->addHiddenInput($key, $value);
}
return $dialog;
}
示例2: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$project_id = $request->getURIData('projectID');
$project = id(new PhabricatorProjectQuery())->setViewer($viewer)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->withIDs(array($project_id))->executeOne();
if (!$project) {
return new Aphront404Response();
}
$this->setProject($project);
$target = $request->getURIData('target');
switch ($target) {
case 'filter':
$title = pht('Set Board Default Filter');
$body = pht('Make the current filter the new default filter for this board? ' . 'All users will see the new filter as the default when they view ' . 'the board.');
$button = pht('Save Default Filter');
$xaction_value = $request->getStr('filter');
$xaction_type = PhabricatorProjectTransaction::TYPE_DEFAULT_FILTER;
break;
case 'sort':
$title = pht('Set Board Default Order');
$body = pht('Make the current sort order the new default order for this board? ' . 'All users will see the new order as the default when they view ' . 'the board.');
$button = pht('Save Default Order');
$xaction_value = $request->getStr('order');
$xaction_type = PhabricatorProjectTransaction::TYPE_DEFAULT_SORT;
break;
default:
return new Aphront404Response();
}
$id = $project->getID();
$view_uri = $this->getApplicationURI("board/{$id}/");
$view_uri = new PhutilURI($view_uri);
foreach ($request->getPassthroughRequestData() as $key => $value) {
$view_uri->setQueryParam($key, $value);
}
if ($request->isFormPost()) {
$xactions = array();
$xactions[] = id(new PhabricatorProjectTransaction())->setTransactionType($xaction_type)->setNewValue($xaction_value);
id(new PhabricatorProjectTransactionEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true)->applyTransactions($project, $xactions);
return id(new AphrontRedirectResponse())->setURI($view_uri);
}
$dialog = $this->newDialog()->setTitle($title)->appendChild($body)->setDisableWorkflowOnCancel(true)->addCancelButton($view_uri)->addSubmitButton($title);
foreach ($request->getPassthroughRequestData() as $key => $value) {
$dialog->addHiddenInput($key, $value);
}
return $dialog;
}
示例3: buildFromRequest
public static function buildFromRequest(AphrontRequest $request)
{
$user = $request->getUser();
if (!$user->getPHID()) {
return null;
}
if (!$request->getStr('__draft__')) {
return null;
}
$draft = id(new PhabricatorDraft())->setAuthorPHID($user->getPHID())->setDraftKey($request->getStr('__draft__'));
// If this is a preview, add other data. If not, leave the draft empty so
// that replaceOrDelete() will delete it.
if ($request->isPreviewRequest()) {
$other_data = $request->getPassthroughRequestData();
unset($other_data['comment']);
$draft->setDraft($request->getStr('comment'))->setMetadata($other_data);
}
return $draft;
}
示例4: decodeConduitParams
private function decodeConduitParams(AphrontRequest $request, $method)
{
// Look for parameters from the Conduit API Console, which are encoded
// as HTTP POST parameters in an array, e.g.:
//
// params[name]=value¶ms[name2]=value2
//
// The fields are individually JSON encoded, since we require users to
// enter JSON so that we avoid type ambiguity.
$params = $request->getArr('params', null);
if ($params !== null) {
foreach ($params as $key => $value) {
if ($value == '') {
// Interpret empty string null (e.g., the user didn't type anything
// into the box).
$value = 'null';
}
$decoded_value = json_decode($value, true);
if ($decoded_value === null && strtolower($value) != 'null') {
// When json_decode() fails, it returns null. This almost certainly
// indicates that a user was using the web UI and didn't put quotes
// around a string value. We can either do what we think they meant
// (treat it as a string) or fail. For now, err on the side of
// caution and fail. In the future, if we make the Conduit API
// actually do type checking, it might be reasonable to treat it as
// a string if the parameter type is string.
throw new Exception(pht("The value for parameter '%s' is not valid JSON. All " . "parameters must be encoded as JSON values, including strings " . "(which means you need to surround them in double quotes). " . "Check your syntax. Value was: %s.", $key, $value));
}
$params[$key] = $decoded_value;
}
$metadata = idx($params, '__conduit__', array());
unset($params['__conduit__']);
return array($metadata, $params);
}
// Otherwise, look for a single parameter called 'params' which has the
// entire param dictionary JSON encoded.
$params_json = $request->getStr('params');
if (strlen($params_json)) {
$params = null;
try {
$params = phutil_json_decode($params_json);
} catch (PhutilJSONParserException $ex) {
throw new PhutilProxyException(pht("Invalid parameter information was passed to method '%s'.", $method), $ex);
}
$metadata = idx($params, '__conduit__', array());
unset($params['__conduit__']);
return array($metadata, $params);
}
// If we do not have `params`, assume this is a simple HTTP request with
// HTTP key-value pairs.
$params = array();
$metadata = array();
foreach ($request->getPassthroughRequestData() as $key => $value) {
$meta_key = ConduitAPIMethod::getParameterMetadataKey($key);
if ($meta_key !== null) {
$metadata[$meta_key] = $value;
} else {
$params[$key] = $value;
}
}
return array($metadata, $params);
}