You are here

public function SalesforceCommands::describeMetadata in Salesforce Suite 8.4

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

Retrieve object metadata.

@command salesforce:describe-metadata @aliases sfdom,sf-describe-metadata

@field-labels actionOverrides: ActionOverrides activateable: Activateable compactLayoutable: CompactLayoutable createable: Createable custom: Custom customSetting: CustomSetting deletable: Deletable deprecatedAndHidden: DeprecatedAndHidden feedEnabled: FeedEnabled hasSubtypes: HasSubtypes isSubtype: IsSubtype keyPrefix: KeyPrefix label: Label labelPlural: LabelPlural layoutable: Layoutable listviewable: Listviewable lookupLayoutable: LookupLayoutable mergeable: Mergeable mruEnabled: MruEnabled name: Name namedLayoutInfos: NamedLayoutInfos networkScopeFieldName: NetworkScopeFieldName queryable: Queryable replicateable: Replicateable retrieveable: Retrieveable searchLayoutable: SearchLayoutable searchable: Searchable supportedScopes: SupportedScopes triggerable: Triggerable undeletable: Undeletable updateable: Updateable urls: Urls

Parameters

string $object: The object name in Salesforce.

Return value

\Consolidation\OutputFormatters\StructuredData\PropertyList|null The metadata, or null if object was not found.

Throws

\Exception

File

src/Commands/SalesforceCommands.php, line 302

Class

SalesforceCommands
A Drush commandfile.

Namespace

Drupal\salesforce\Commands

Code

public function describeMetadata($object) {
  $objectDescription = $this->client
    ->objectDescribe($object);
  if (!is_object($objectDescription)) {
    $this
      ->logger()
      ->error(dt('Could not load data for object !object', [
      '!object' => $object,
    ]));
    return;
  }
  $data = $objectDescription->data;

  // Return if we cannot load any data.
  unset($data['fields'], $data['childRelationships'], $data['recordTypeInfos']);
  foreach ($data as $k => &$v) {
    if ($k == 'supportedScopes') {
      array_walk($v, function (&$value, $key) {
        $value = $value['name'] . ' (' . $value['label'] . ')';
      });
    }
    if (is_array($v)) {
      if (empty($v)) {
        $v = '';
      }
      else {
        $v = implode("\n", $v) . "\n";
      }
    }
  }
  return new PropertyList($data);
}