You are here

public function SalesforceCommands::describeFields in Salesforce Suite 8.4

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

Retrieve all the metadata for an object.

@command salesforce:describe-fields @aliases salesforce:describe-object,sfdo,sfdf,sf-describe-fields @usage drush sfdo Contact Show metadata about Contact SObject type.

@field-labels aggregatable: Aggregatable aiPredictionField: AiPredictionField autoNumber: AutoNumber byteLength: ByteLength calculated: Calculated calculatedFormula: CalculatedFormula cascadeDelete: CascadeDelete caseSensitive: CaseSensitive compoundFieldName: CompoundFieldName controllerName: ControllerName createable: Createable custom: Custom defaultValue: DefaultValue defaultValueFormula: DefaultValueFormula defaultedOnCreate: DefaultedOnCreate dependentPicklist: DependentPicklist deprecatedAndHidden: DeprecatedAndHidden digits: Digits displayLocationInDecimal: DisplayLocationInDecimal encrypted: Encrypted externalId: ExternalId extraTypeInfo: ExtraTypeInfo filterable: Filterable filteredLookupInfo: FilteredLookupInfo formulaTreatNullNumberAsZero: FormulaTreatNullNumberAsZero groupable: Groupable highScaleNumber: HighScaleNumber htmlFormatted: HtmlFormatted idLookup: IdLookup inlineHelpText: InlineHelpText label: Label length: Length mask: Mask maskType: MaskType name: Name nameField: NameField namePointing: NamePointing nillable: Nillable permissionable: Permissionable picklistValues: PicklistValues polymorphicForeignKey: PolymorphicForeignKey precision: Precision queryByDistance: QueryByDistance referenceTargetField: ReferenceTargetField referenceTo: ReferenceTo relationshipName: RelationshipName relationshipOrder: RelationshipOrder restrictedDelete: RestrictedDelete restrictedPicklist: RestrictedPicklist scale: Scale searchPrefilterable: SearchPrefilterable soapType: SoapType sortable: Sortable type: Type unique: Unique updateable: Updateable writeRequiresMasterRead: WriteRequiresMasterRead

@default-fields label,name,type

Parameters

string $object: The object name in Salesforce.

Return value

\Consolidation\OutputFormatters\StructuredData\RowsOfFields|null The fields, or null if the object was not found.

Throws

\Exception

1 call to SalesforceCommands::describeFields()
SalesforceCommands::describeObject in src/Commands/SalesforceCommands.php
Retrieve all the metadata for an object, including fields.

File

src/Commands/SalesforceCommands.php, line 406

Class

SalesforceCommands
A Drush commandfile.

Namespace

Drupal\salesforce\Commands

Code

public function describeFields($object) {
  $objectDescription = $this->client
    ->objectDescribe($object);

  // Return if we cannot load any data.
  if (!is_object($objectDescription)) {
    $this
      ->logger()
      ->error(dt('Could not load data for object !object', [
      '!object' => $object,
    ]));
    return;
  }
  foreach ($objectDescription
    ->getFields() as $field => $data) {
    if (!empty($data['picklistValues'])) {
      $fix_data = [];
      foreach ($data['picklistValues'] as $value) {
        $fix_data[] = $value['value'] . ' (' . $value['label'] . ')';
      }
      $data['picklistValues'] = $fix_data;
    }
    foreach ($data as $k => &$v) {
      if (is_array($v)) {
        $v = implode("\n", $v);
      }
    }
    $rows[$field] = $data;
  }
  return new RowsOfFields($rows);
}