SalesforceAuthRevokeForm.php in Salesforce Suite 5.0.x
File
src/Form/SalesforceAuthRevokeForm.php
View source
<?php
namespace Drupal\salesforce\Form;
use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\salesforce\Entity\SalesforceAuthConfig;
class SalesforceAuthRevokeForm extends EntityConfirmFormBase {
public function getQuestion() {
return $this
->t('Are you sure you want to revoke authorization for Auth Config %name?', [
'%name' => $this->entity
->label(),
]);
}
public function getCancelUrl() {
return $this->entity
->toUrl('collection');
}
public function getConfirmText() {
return $this
->t('Revoke Auth Token');
}
public function submitForm(array &$form, FormStateInterface $form_state) {
if (!$this->entity instanceof SalesforceAuthConfig) {
return;
}
$this->entity
->getPlugin()
->revokeAccessToken();
$this
->messenger()
->addStatus($this
->t('Auth token for %label was revoked.', [
'%label' => $this->entity
->label(),
]));
$form_state
->setRedirectUrl($this
->getCancelUrl());
}
}