SalesforceAuthListBuilder.php in Salesforce Suite 8.4
File
src/Controller/SalesforceAuthListBuilder.php
View source
<?php
namespace Drupal\salesforce\Controller;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityInterface;
use Drupal\salesforce\Entity\SalesforceAuthConfig;
class SalesforceAuthListBuilder extends ConfigEntityListBuilder {
public function buildRow(EntityInterface $entity) {
$plugin = $entity
->getPlugin();
$row['default'] = $entity
->authManager()
->getConfig() && $entity
->authManager()
->getConfig()
->id() == $entity
->id() ? $this
->t('Default') : '';
$row['label'] = $entity
->label();
$row['url'] = $plugin
->getCredentials()
->getLoginUrl();
$row['key'] = substr($plugin
->getCredentials()
->getConsumerKey(), 0, 16) . '...';
$row['type'] = $plugin
->label();
$row['status'] = $plugin
->hasAccessToken() ? 'Authorized' : 'Missing';
return $row + parent::buildRow($entity);
}
public function getDefaultOperations(EntityInterface $entity) {
$operations = parent::getDefaultOperations($entity);
$operations['edit']['title'] = $this
->t('Edit / Re-auth');
$operations['edit']['url'] = $entity
->toUrl('edit-form');
if (!$entity instanceof SalesforceAuthConfig || !$entity
->getPlugin()
->hasAccessToken() || !$entity
->hasLinkTemplate('revoke')) {
return $operations;
}
$operations['revoke'] = [
'title' => $this
->t('Revoke'),
'weight' => 20,
'url' => $this
->ensureDestination($entity
->toUrl('revoke')),
];
return $operations;
}
public function buildHeader() {
$header['default'] = [
'data' => '',
];
$header['label'] = [
'data' => $this
->t('Label'),
];
$header['url'] = [
'data' => $this
->t('Login URL'),
];
$header['key'] = [
'data' => $this
->t('Consumer Key'),
];
$header['type'] = [
'data' => $this
->t('Auth Type'),
];
$header['status'] = [
'data' => $this
->t('Token Status'),
];
return $header + parent::buildHeader();
}
}