You are here

public function SalesforceAuthListBuilder::getDefaultOperations in Salesforce Suite 5.0.x

Same name and namespace in other branches
  1. 8.4 src/Controller/SalesforceAuthListBuilder.php \Drupal\salesforce\Controller\SalesforceAuthListBuilder::getDefaultOperations()

Gets this list's default operations.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity the operations are for.

Return value

array The array structure is identical to the return value of self::getOperations().

Overrides ConfigEntityListBuilder::getDefaultOperations

File

src/Controller/SalesforceAuthListBuilder.php, line 36

Class

SalesforceAuthListBuilder
List builder for salesforce_auth.

Namespace

Drupal\salesforce\Controller

Code

public function getDefaultOperations(EntityInterface $entity) {
  $operations = parent::getDefaultOperations($entity);
  $operations['edit']['title'] = $this
    ->t('Edit / Re-auth');

  // Having "destination" on edit link breaks OAuth.
  // Add a "revoke" action if we have a token.
  $operations['edit']['url'] = $entity
    ->toUrl('edit-form');
  if (!$entity instanceof SalesforceAuthConfig || !$entity
    ->getPlugin()
    ->hasAccessToken() || !$entity
    ->hasLinkTemplate('revoke')) {
    return $operations;
  }

  // Add a "revoke" action if we have a token.
  $operations['revoke'] = [
    'title' => $this
      ->t('Revoke'),
    'weight' => 20,
    'url' => $this
      ->ensureDestination($entity
      ->toUrl('revoke')),
  ];
  return $operations;
}