public function SalesforceOAuthPlugin::submitConfigurationForm in Salesforce Suite 8.4
Same name and namespace in other branches
- 5.0.x modules/salesforce_oauth/src/Plugin/SalesforceAuthProvider/SalesforceOAuthPlugin.php \Drupal\salesforce_oauth\Plugin\SalesforceAuthProvider\SalesforceOAuthPlugin::submitConfigurationForm()
Form submission handler.
Parameters
array $form: An associative array containing the structure of the plugin form as built by static::buildConfigurationForm().
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().
Overrides SalesforceAuthProviderPluginBase::submitConfigurationForm
File
- modules/
salesforce_oauth/ src/ Plugin/ SalesforceAuthProvider/ SalesforceOAuthPlugin.php, line 71
Class
- SalesforceOAuthPlugin
- Salesforce OAuth user-agent flow auth provider plugin.
Namespace
Drupal\salesforce_oauth\Plugin\SalesforceAuthProviderCode
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
parent::submitConfigurationForm($form, $form_state);
// Write the config id to private temp store, so that we can use the same
// callback URL for all OAuth applications in Salesforce.
/** @var \Drupal\Core\TempStore\PrivateTempStore $tempstore */
$tempstore = \Drupal::service('tempstore.private')
->get('salesforce_oauth');
$tempstore
->set('config_id', $form_state
->getValue('id'));
try {
$path = $this
->getAuthorizationEndpoint();
$query = [
'redirect_uri' => $this
->getCredentials()
->getCallbackUrl(),
'response_type' => 'code',
'client_id' => $this
->getCredentials()
->getConsumerKey(),
];
// Send the user along to the Salesforce OAuth login form. If successful,
// the user will be redirected to {redirect_uri} to complete the OAuth
// handshake, and thence to the entity listing. Upon failure, the user
// redirect URI will send the user back to the edit form.
$form_state
->setResponse(new TrustedRedirectResponse(Url::fromUri($path . '?' . http_build_query($query))
->toString()));
} catch (\Exception $e) {
$form_state
->setError($form, $this
->t("Error during authorization: %message", [
'%message' => $e
->getMessage(),
]));
}
}