public function BusinessRulesUtil::getBundleFields in Business Rules 2.x
Same name and namespace in other branches
- 8 src/Util/BusinessRulesUtil.php \Drupal\business_rules\Util\BusinessRulesUtil::getBundleFields()
Helper function to return all fields from one bundle.
Parameters
string $entityType: The entity type.
string $bundle: The entity bundle.
Return value
array Array of fields ['type' => 'description']
File
- src/Util/ BusinessRulesUtil.php, line 389 
Class
- BusinessRulesUtil
- Class BusinessRulesUtil.
Namespace
Drupal\business_rules\UtilCode
public function getBundleFields($entityType, $bundle) {
  if (empty($entityType) || empty($bundle)) {
    return [];
  }
  $fields = $this->entityFieldManager
    ->getFieldDefinitions($entityType, $bundle);
  foreach ($fields as $field_name => $field_storage) {
    $field_type = $field_storage
      ->getType();
    $options[$field_name] = $this
      ->t('@type: @field', [
      '@type' => $field_type,
      '@field' => $field_storage
        ->getLabel() . " [{$field_name}]",
    ]);
  }
  asort($options);
  return $options;
}