本文整理汇总了PHP中AphrontRequest::getStrList方法的典型用法代码示例。如果您正苦于以下问题:PHP AphrontRequest::getStrList方法的具体用法?PHP AphrontRequest::getStrList怎么用?PHP AphrontRequest::getStrList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AphrontRequest
的用法示例。
在下文中一共展示了AphrontRequest::getStrList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRequestDataAccess
public function testRequestDataAccess()
{
$r = new AphrontRequest('http://example.com/', '/');
$r->setRequestData(array('str_empty' => '', 'str' => 'derp', 'str_true' => 'true', 'str_false' => 'false', 'zero' => '0', 'one' => '1', 'arr_empty' => array(), 'arr_num' => array(1, 2, 3), 'comma' => ',', 'comma_1' => 'a, b', 'comma_2' => ' ,a ,, b ,,,, ,, ', 'comma_3' => '0', 'comma_4' => 'a, a, b, a', 'comma_5' => "a\nb, c\n\nd\n\n\n,\n"));
$this->assertEqual(1, $r->getInt('one'));
$this->assertEqual(0, $r->getInt('zero'));
$this->assertEqual(null, $r->getInt('does-not-exist'));
$this->assertEqual(0, $r->getInt('str_empty'));
$this->assertEqual(true, $r->getBool('one'));
$this->assertEqual(false, $r->getBool('zero'));
$this->assertEqual(true, $r->getBool('str_true'));
$this->assertEqual(false, $r->getBool('str_false'));
$this->assertEqual(true, $r->getBool('str'));
$this->assertEqual(null, $r->getBool('does-not-exist'));
$this->assertEqual(false, $r->getBool('str_empty'));
$this->assertEqual('derp', $r->getStr('str'));
$this->assertEqual('', $r->getStr('str_empty'));
$this->assertEqual(null, $r->getStr('does-not-exist'));
$this->assertEqual(array(), $r->getArr('arr_empty'));
$this->assertEqual(array(1, 2, 3), $r->getArr('arr_num'));
$this->assertEqual(null, $r->getArr('str_empty', null));
$this->assertEqual(null, $r->getArr('str_true', null));
$this->assertEqual(null, $r->getArr('does-not-exist', null));
$this->assertEqual(array(), $r->getArr('does-not-exist'));
$this->assertEqual(array(), $r->getStrList('comma'));
$this->assertEqual(array('a', 'b'), $r->getStrList('comma_1'));
$this->assertEqual(array('a', 'b'), $r->getStrList('comma_2'));
$this->assertEqual(array('0'), $r->getStrList('comma_3'));
$this->assertEqual(array('a', 'a', 'b', 'a'), $r->getStrList('comma_4'));
$this->assertEqual(array('a', 'b', 'c', 'd'), $r->getStrList('comma_5'));
$this->assertEqual(array(), $r->getStrList('does-not-exist'));
$this->assertEqual(null, $r->getStrList('does-not-exist', null));
$this->assertEqual(true, $r->getExists('str'));
$this->assertEqual(false, $r->getExists('does-not-exist'));
}
示例2: buildSavedQueryFromRequest
public function buildSavedQueryFromRequest(AphrontRequest $request)
{
$saved = new PhabricatorSavedQuery();
$object_monograms = $request->getStrList('objectMonograms');
$saved->setParameter('objectMonograms', $object_monograms);
$ids = $request->getStrList('ids');
foreach ($ids as $key => $id) {
if (!$id || !is_numeric($id)) {
unset($ids[$key]);
} else {
$ids[$key] = $id;
}
}
$saved->setParameter('ids', $ids);
return $saved;
}
示例3: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$e_file = true;
$errors = array();
if ($request->isDialogFormPost()) {
$file_phids = $request->getStrList('filePHIDs');
if ($file_phids) {
$files = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs($file_phids)->setRaisePolicyExceptions(true)->execute();
} else {
$files = array();
}
if ($files) {
$results = array();
foreach ($files as $file) {
$results[] = $file->getDragAndDropDictionary();
}
$content = array('files' => $results);
return id(new AphrontAjaxResponse())->setContent($content);
} else {
$e_file = pht('Required');
$errors[] = pht('You must choose a file to upload.');
}
}
if ($request->getURIData('single')) {
$allow_multiple = false;
} else {
$allow_multiple = true;
}
$form = id(new AphrontFormView())->appendChild(id(new PHUIFormFileControl())->setName('filePHIDs')->setLabel(pht('Upload File'))->setAllowMultiple($allow_multiple)->setError($e_file));
return $this->newDialog()->setTitle(pht('File'))->setErrors($errors)->appendForm($form)->addSubmitButton(pht('Upload'))->addCancelButton('/');
}
示例4: getParameterValue
protected function getParameterValue(AphrontRequest $request, $key)
{
$list = $request->getArr($key, null);
if ($list === null) {
$list = $request->getStrList($key);
}
return $list;
}
示例5: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$commit = id(new PhabricatorRepositoryCommit())->load($id);
if (!$commit) {
return new Aphront404Response();
}
$xactions = array();
$action = $request->getStr('action');
if ($action != PhabricatorAuditActionConstants::COMMENT) {
$action_xaction = id(new PhabricatorAuditTransaction())->setAuthorPHID($viewer->getPHID())->setObjectPHID($commit->getPHID())->setTransactionType(PhabricatorAuditActionConstants::ACTION)->setNewValue($action);
$auditors = $request->getStrList('auditors');
if ($action == PhabricatorAuditActionConstants::ADD_AUDITORS && $auditors) {
$action_xaction->setTransactionType($action);
$action_xaction->setNewValue(array_fuse($auditors));
}
$ccs = $request->getStrList('ccs');
if ($action == PhabricatorAuditActionConstants::ADD_CCS && $ccs) {
$action_xaction->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS);
// NOTE: This doesn't get processed before use, so just provide fake
// values.
$action_xaction->setOldValue(array());
$action_xaction->setNewValue($ccs);
}
$xactions[] = $action_xaction;
}
$content = $request->getStr('content');
if (strlen($content)) {
$xactions[] = id(new PhabricatorAuditTransaction())->setAuthorPHID($viewer->getPHID())->setObjectPHID($commit->getPHID())->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)->attachComment(id(new PhabricatorAuditTransactionComment())->setContent($content));
}
$phids = array();
foreach ($xactions as $xaction) {
$phids[] = $xaction->getRequiredHandlePHIDs();
}
$phids = array_mergev($phids);
$handles = $this->loadViewerHandles($phids);
foreach ($xactions as $xaction) {
$xaction->setHandles($handles);
}
$view = id(new PhabricatorAuditTransactionView())->setIsPreview(true)->setUser($viewer)->setObjectPHID($commit->getPHID())->setTransactions($xactions);
id(new PhabricatorDraft())->setAuthorPHID($viewer->getPHID())->setDraftKey('diffusion-audit-' . $id)->setDraft($content)->replaceOrDelete();
return id(new AphrontAjaxResponse())->setContent(hsprintf('%s', $view));
}
示例6: buildSavedQueryFromRequest
public function buildSavedQueryFromRequest(AphrontRequest $request)
{
$saved = new PhabricatorSavedQuery();
$saved->setParameter('isStable', $request->getStr('isStable'));
$saved->setParameter('isUnstable', $request->getStr('isUnstable'));
$saved->setParameter('isDeprecated', $request->getStr('isDeprecated'));
$saved->setParameter('applicationNames', $request->getStrList('applicationNames'));
$saved->setParameter('nameContains', $request->getStr('nameContains'));
return $saved;
}
示例7: buildSavedQueryFromRequest
public function buildSavedQueryFromRequest(AphrontRequest $request)
{
$saved = new PhabricatorSavedQuery();
$saved->setParameter('callsigns', $request->getStrList('callsigns'));
$saved->setParameter('status', $request->getStr('status'));
$saved->setParameter('order', $request->getStr('order'));
$saved->setParameter('hosted', $request->getStr('hosted'));
$saved->setParameter('types', $request->getArr('types'));
$saved->setParameter('name', $request->getStr('name'));
$saved->setParameter('anyProjectPHIDs', $request->getArr('anyProjects'));
return $saved;
}
示例8: buildSavedQueryFromRequest
public function buildSavedQueryFromRequest(AphrontRequest $request)
{
$saved = new PhabricatorSavedQuery();
$saved->setParameter('usernames', $request->getStrList('usernames'));
$saved->setParameter('nameLike', $request->getStr('nameLike'));
$saved->setParameter('isAdmin', $request->getStr('isAdmin'));
$saved->setParameter('isDisabled', $request->getStr('isDisabled'));
$saved->setParameter('isSystemAgent', $request->getStr('isSystemAgent'));
$saved->setParameter('needsApproval', $request->getStr('needsApproval'));
$saved->setParameter('createdStart', $request->getStr('createdStart'));
$saved->setParameter('createdEnd', $request->getStr('createdEnd'));
$this->readCustomFieldsFromRequest($request, $saved);
return $saved;
}
示例9: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
if (!$request->validateCSRF()) {
return new Aphront400Response();
}
$cancel_uri = $this->getApplicationURI();
$ids = $request->getStrList('h');
if ($ids) {
$files = id(new PhabricatorFileQuery())->setViewer($viewer)->withIDs($ids)->setRaisePolicyExceptions(true)->execute();
} else {
$files = array();
}
if (!$files) {
return $this->newDialog()->setTitle(pht('Nothing Uploaded'))->appendParagraph(pht('Drag and drop .ics files to upload them and import them into ' . 'Calendar.'))->addCancelButton($cancel_uri, pht('Done'));
}
$engine = new PhabricatorCalendarICSFileImportEngine();
$imports = array();
foreach ($files as $file) {
$import = PhabricatorCalendarImport::initializeNewCalendarImport($viewer, clone $engine);
$xactions = array();
$xactions[] = id(new PhabricatorCalendarImportTransaction())->setTransactionType(PhabricatorCalendarImportICSFileTransaction::TRANSACTIONTYPE)->setNewValue($file->getPHID());
$editor = id(new PhabricatorCalendarImportEditor())->setActor($viewer)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true)->setContentSourceFromRequest($request);
$editor->applyTransactions($import, $xactions);
$imports[] = $import;
}
$import_phids = mpull($imports, 'getPHID');
$events = id(new PhabricatorCalendarEventQuery())->setViewer($viewer)->withImportSourcePHIDs($import_phids)->execute();
if (count($events) == 1) {
// The user imported exactly one event. This is consistent with dropping
// a .ics file from an email; just take them to the event.
$event = head($events);
$next_uri = $event->getURI();
} else {
if (count($imports) > 1) {
// The user imported multiple different files. Take them to a summary
// list of generated import activity.
$source_phids = implode(',', $import_phids);
$next_uri = '/calendar/import/log/?importSourcePHIDs=' . $source_phids;
} else {
// The user imported one file, which had zero or more than one event.
// Take them to the import detail page.
$import = head($imports);
$next_uri = $import->getURI();
}
}
return id(new AphrontRedirectResponse())->setURI($next_uri);
}
示例10: handleRequest
public function handleRequest(AphrontRequest $request)
{
$engine_key = $request->getURIData('engineKey');
$this->setEngineKey($engine_key);
$key = $request->getURIData('key');
$viewer = $this->getViewer();
$config = id(new PhabricatorEditEngineConfigurationQuery())->setViewer($viewer)->withEngineKeys(array($engine_key))->withIdentifiers(array($key))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
if (!$config) {
return id(new Aphront404Response());
}
$cancel_uri = "/transactions/editengine/{$engine_key}/view/{$key}/";
$reorder_uri = "/transactions/editengine/{$engine_key}/reorder/{$key}/";
if ($request->isFormPost()) {
$xactions = array();
$key_order = $request->getStrList('keyOrder');
$type_order = PhabricatorEditEngineConfigurationTransaction::TYPE_ORDER;
$xactions[] = id(new PhabricatorEditEngineConfigurationTransaction())->setTransactionType($type_order)->setNewValue($key_order);
$editor = id(new PhabricatorEditEngineConfigurationEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnMissingFields(true)->setContinueOnNoEffect(true);
$editor->applyTransactions($config, $xactions);
return id(new AphrontRedirectResponse())->setURI($cancel_uri);
}
$engine = $config->getEngine();
$fields = $engine->getFieldsForConfig($config);
$list_id = celerity_generate_unique_node_id();
$input_id = celerity_generate_unique_node_id();
$list = id(new PHUIObjectItemListView())->setUser($viewer)->setID($list_id)->setFlush(true);
$key_order = array();
foreach ($fields as $field) {
if (!$field->getIsReorderable()) {
continue;
}
$label = $field->getLabel();
$key = $field->getKey();
if ($label !== null) {
$header = $label;
} else {
$header = $key;
}
$item = id(new PHUIObjectItemView())->setHeader($header)->setGrippable(true)->addSigil('editengine-form-field')->setMetadata(array('fieldKey' => $key));
$list->addItem($item);
$key_order[] = $key;
}
Javelin::initBehavior('editengine-reorder-fields', array('listID' => $list_id, 'inputID' => $input_id, 'reorderURI' => $reorder_uri));
$note = id(new PHUIInfoView())->appendChild(pht('Drag and drop fields to reorder them.'))->setSeverity(PHUIInfoView::SEVERITY_NOTICE);
$input = phutil_tag('input', array('type' => 'hidden', 'name' => 'keyOrder', 'value' => implode(', ', $key_order), 'id' => $input_id));
return $this->newDialog()->setTitle(pht('Reorder Fields'))->setWidth(AphrontDialogView::WIDTH_FORM)->appendChild($note)->appendChild($list)->appendChild($input)->addSubmitButton(pht('Save Changes'))->addCancelButton($cancel_uri);
}
示例11: processDiffusionRequest
protected function processDiffusionRequest(AphrontRequest $request)
{
$user = $request->getUser();
$drequest = $this->diffusionRequest;
$repository = $drequest->getRepository();
$repository = id(new PhabricatorRepositoryQuery())->setViewer($user)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->withIDs(array($repository->getID()))->executeOne();
if (!$repository) {
return new Aphront404Response();
}
$edit_uri = $this->getRepositoryControllerURI($repository, 'edit/');
$v_sources = $repository->getSymbolSources();
$v_languages = $repository->getSymbolLanguages();
if ($v_languages) {
$v_languages = implode(', ', $v_languages);
}
$errors = array();
if ($request->isFormPost()) {
$v_sources = $request->getArr('sources');
$v_languages = $request->getStrList('languages');
$v_languages = array_map('phutil_utf8_strtolower', $v_languages);
if (!$errors) {
$xactions = array();
$template = id(new PhabricatorRepositoryTransaction());
$type_sources = PhabricatorRepositoryTransaction::TYPE_SYMBOLS_SOURCES;
$type_lang = PhabricatorRepositoryTransaction::TYPE_SYMBOLS_LANGUAGE;
$xactions[] = id(clone $template)->setTransactionType($type_sources)->setNewValue($v_sources);
$xactions[] = id(clone $template)->setTransactionType($type_lang)->setNewValue($v_languages);
try {
id(new PhabricatorRepositoryEditor())->setContinueOnNoEffect(true)->setContentSourceFromRequest($request)->setActor($user)->applyTransactions($repository, $xactions);
return id(new AphrontRedirectResponse())->setURI($edit_uri);
} catch (Exception $ex) {
$errors[] = $ex->getMessage();
}
}
}
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Edit Symbols'));
$title = pht('Edit %s', $repository->getName());
$form = id(new AphrontFormView())->setUser($user)->appendRemarkupInstructions($this->getInstructions())->appendChild(id(new AphrontFormTextControl())->setName('languages')->setLabel(pht('Indexed Languages'))->setCaption(pht('File extensions, separate with commas, for example: php, py. ' . 'Leave blank for "any".'))->setValue($v_languages))->appendControl(id(new AphrontFormTokenizerControl())->setName('sources')->setLabel(pht('Uses Symbols From'))->setDatasource(new DiffusionRepositoryDatasource())->setValue($v_sources))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Save'))->addCancelButton($edit_uri));
$object_box = id(new PHUIObjectBoxView())->setHeaderText($title)->setForm($form)->setFormErrors($errors);
return $this->buildApplicationPage(array($crumbs, $object_box), array('title' => $title));
}
示例12: getParameterValue
protected function getParameterValue(AphrontRequest $request, $key)
{
$value = $request->getStrList($key);
if ($value) {
return head($value);
}
// NOTE: At least for now, we'll attempt to read a direct upload if we
// miss on a PHID. Currently, PHUIFormFileControl does a client-side
// upload on workflow forms (which is good) but doesn't have a hook for
// non-workflow forms (which isn't as good). Giving it a hook is desirable,
// but complicated. Even if we do hook it, it may be reasonable to keep
// this code around as a fallback if the client-side JS goes awry.
$file_key = $this->getFileKey($key);
if (!$request->getFileExists($file_key)) {
return null;
}
$viewer = $this->getViewer();
$file = PhabricatorFile::newFromPHPUpload(idx($_FILES, $file_key), array('authorPHID' => $viewer->getPHID(), 'viewPolicy' => PhabricatorPolicies::POLICY_NOONE));
return $file->getPHID();
}
示例13: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $this->getViewer();
$engine_class = $request->getURIData('engine');
$request->validateCSRF();
$base_class = 'PhabricatorApplicationSearchEngine';
if (!is_subclass_of($engine_class, $base_class)) {
return new Aphront400Response();
}
$engine = newv($engine_class, array());
$engine->setViewer($viewer);
$queries = $engine->loadAllNamedQueries();
$queries = mpull($queries, null, 'getQueryKey');
$order = $request->getStrList('order');
$queries = array_select_keys($queries, $order) + $queries;
$sequence = 1;
foreach ($queries as $query) {
$query->setSequence($sequence++);
$query->save();
}
return id(new AphrontAjaxResponse());
}
示例14: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$panel = id(new PhabricatorDashboardPanelQuery())->setViewer($viewer)->withIDs(array($id))->executeOne();
if (!$panel) {
return new Aphront404Response();
}
if ($request->isAjax()) {
$parent_phids = $request->getStrList('parentPanelPHIDs', null);
if ($parent_phids === null) {
throw new Exception(pht('Required parameter `parentPanelPHIDs` is not present in ' . 'request.'));
}
} else {
$parent_phids = array();
}
$rendered_panel = id(new PhabricatorDashboardPanelRenderingEngine())->setViewer($viewer)->setPanel($panel)->setParentPanelPHIDs($parent_phids)->setHeaderMode($request->getStr('headerMode'))->setDashboardID($request->getInt('dashboardID'))->renderPanel();
if ($request->isAjax()) {
return id(new AphrontAjaxResponse())->setContent(array('panelMarkup' => hsprintf('%s', $rendered_panel)));
}
$crumbs = $this->buildApplicationCrumbs()->addTextCrumb(pht('Panels'), $this->getApplicationURI('panel/'))->addTextCrumb($panel->getMonogram(), '/' . $panel->getMonogram())->addTextCrumb(pht('Standalone View'));
$view = id(new PHUIBoxView())->addClass('dashboard-view')->appendChild($rendered_panel);
return $this->buildApplicationPage(array($crumbs, $view), array('title' => array(pht('Panel'), $panel->getName())));
}
示例15: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $this->getViewer();
$server = new PhabricatorOAuthServer();
$client_phid = $request->getStr('client_id');
$redirect_uri = $request->getStr('redirect_uri');
$response_type = $request->getStr('response_type');
// state is an opaque value the client sent us for their own purposes
// we just need to send it right back to them in the response!
$state = $request->getStr('state');
if (!$client_phid) {
return $this->buildErrorResponse('invalid_request', pht('Malformed Request'), pht('Required parameter %s was not present in the request.', phutil_tag('strong', array(), 'client_id')));
}
// We require that users must be able to see an OAuth application
// in order to authorize it. This allows an application's visibility
// policy to be used to restrict authorized users.
try {
$client = id(new PhabricatorOAuthServerClientQuery())->setViewer($viewer)->withPHIDs(array($client_phid))->executeOne();
} catch (PhabricatorPolicyException $ex) {
$ex->setContext(self::CONTEXT_AUTHORIZE);
throw $ex;
}
$server->setUser($viewer);
$is_authorized = false;
$authorization = null;
$uri = null;
$name = null;
// one giant try / catch around all the exciting database stuff so we
// can return a 'server_error' response if something goes wrong!
try {
if (!$client) {
return $this->buildErrorResponse('invalid_request', pht('Invalid Client Application'), pht('Request parameter %s does not specify a valid client application.', phutil_tag('strong', array(), 'client_id')));
}
if ($client->getIsDisabled()) {
return $this->buildErrorResponse('invalid_request', pht('Application Disabled'), pht('The %s OAuth application has been disabled.', phutil_tag('strong', array(), 'client_id')));
}
$name = $client->getName();
$server->setClient($client);
if ($redirect_uri) {
$client_uri = new PhutilURI($client->getRedirectURI());
$redirect_uri = new PhutilURI($redirect_uri);
if (!$server->validateSecondaryRedirectURI($redirect_uri, $client_uri)) {
return $this->buildErrorResponse('invalid_request', pht('Invalid Redirect URI'), pht('Request parameter %s specifies an invalid redirect URI. ' . 'The redirect URI must be a fully-qualified domain with no ' . 'fragments, and must have the same domain and at least ' . 'the same query parameters as the redirect URI the client ' . 'registered.', phutil_tag('strong', array(), 'redirect_uri')));
}
$uri = $redirect_uri;
} else {
$uri = new PhutilURI($client->getRedirectURI());
}
if (empty($response_type)) {
return $this->buildErrorResponse('invalid_request', pht('Invalid Response Type'), pht('Required request parameter %s is missing.', phutil_tag('strong', array(), 'response_type')));
}
if ($response_type != 'code') {
return $this->buildErrorResponse('unsupported_response_type', pht('Unsupported Response Type'), pht('Request parameter %s specifies an unsupported response type. ' . 'Valid response types are: %s.', phutil_tag('strong', array(), 'response_type'), implode(', ', array('code'))));
}
$requested_scope = $request->getStrList('scope');
$requested_scope = array_fuse($requested_scope);
$scope = PhabricatorOAuthServerScope::filterScope($requested_scope);
// NOTE: We're always requiring a confirmation dialog to redirect.
// Partly this is a general defense against redirect attacks, and
// partly this shakes off anchors in the URI (which are not shaken
// by 302'ing).
$auth_info = $server->userHasAuthorizedClient($scope);
list($is_authorized, $authorization) = $auth_info;
if ($request->isFormPost()) {
if ($authorization) {
$authorization->setScope($scope)->save();
} else {
$authorization = $server->authorizeClient($scope);
}
$is_authorized = true;
}
} catch (Exception $e) {
return $this->buildErrorResponse('server_error', pht('Server Error'), pht('The authorization server encountered an unexpected condition ' . 'which prevented it from fulfilling the request.'));
}
// When we reach this part of the controller, we can be in two states:
//
// 1. The user has not authorized the application yet. We want to
// give them an "Authorize this application?" dialog.
// 2. The user has authorized the application. We want to give them
// a "Confirm Login" dialog.
if ($is_authorized) {
// The second case is simpler, so handle it first. The user either
// authorized the application previously, or has just authorized the
// application. Show them a confirm dialog with a normal link back to
// the application. This shakes anchors from the URI.
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
$auth_code = $server->generateAuthorizationCode($uri);
unset($unguarded);
$full_uri = $this->addQueryParams($uri, array('code' => $auth_code->getCode(), 'scope' => $authorization->getScopeString(), 'state' => $state));
if ($client->getIsTrusted()) {
return id(new AphrontRedirectResponse())->setIsExternal(true)->setURI((string) $full_uri);
}
// TODO: It would be nice to give the user more options here, like
// reviewing permissions, canceling the authorization, or aborting
// the workflow.
$dialog = id(new AphrontDialogView())->setUser($viewer)->setTitle(pht('Authenticate: %s', $name))->appendParagraph(pht('This application ("%s") is authorized to use your Phabricator ' . 'credentials. Continue to complete the authentication workflow.', phutil_tag('strong', array(), $name)))->addCancelButton((string) $full_uri, pht('Continue to Application'));
return id(new AphrontDialogResponse())->setDialog($dialog);
}
// Here, we're confirming authorization for the application.
if ($authorization) {
//.........这里部分代码省略.........