You are here

public function SalesforceCommands::listResources in Salesforce Suite 8.3

Same name and namespace in other branches
  1. 8.4 src/Commands/SalesforceCommands.php \Drupal\salesforce\Commands\SalesforceCommands::listResources()
  2. 5.0.x src/Commands/SalesforceCommands.php \Drupal\salesforce\Commands\SalesforceCommands::listResources()

Lists the resources available for the current API version.

@command salesforce:list-resources @aliases sflr,sf-list-resources @field-labels resource: Resource url: URL @default-fields resource,url

Return value

\Consolidation\OutputFormatters\StructuredData\RowsOfFields|null The resources, or null if resources failed to load.

File

src/Commands/SalesforceCommands.php, line 431

Class

SalesforceCommands
A Drush commandfile.

Namespace

Drupal\salesforce\Commands

Code

public function listResources() {
  $resources = $this->client
    ->listResources();
  if ($resources) {
    foreach ($resources->resources as $resource => $url) {
      $rows[$url] = [
        'resource' => $resource,
        'url' => $url,
      ];
    }
    $this
      ->output()
      ->writeln("The following resources are available:");
    return new RowsOfFields($rows);
  }
  $this
    ->logger()
    ->error('Could not obtain a list of resources!');
}