You are here

protected function FieldValidationRuleSetAddForm::findBundle in Field Validation 8

Handles switching the bundle selector.

2 calls to FieldValidationRuleSetAddForm::findBundle()
FieldValidationRuleSetAddForm::form in src/Form/FieldValidationRuleSetAddForm.php
Gets the actual form array to be built.
FieldValidationRuleSetAddForm::updateBundle in src/Form/FieldValidationRuleSetAddForm.php
Handles switching the configuration type selector.

File

src/Form/FieldValidationRuleSetAddForm.php, line 69

Class

FieldValidationRuleSetAddForm
Controller for FieldValidationRuleSet addition forms.

Namespace

Drupal\field_validation\Form

Code

protected function findBundle($entity_type) {

  //\Drupal::logger('field_validation')->notice('1234:' . $field_name);
  $bundle_options = [
    '' => $this
      ->t('- Select -'),
  ];
  if (empty($entity_type)) {
    return $bundle_options;
  }
  else {

    //drupal_set_message($entity_type);
    $bundles = \Drupal::service('entity_type.bundle.info')
      ->getBundleInfo($entity_type);
    foreach ($bundles as $key => $bundle) {

      //drupal_set_message(var_export($bundle, true));
      $bundle_options[$key] = isset($bundle['label']) ? $bundle['label'] : $key;
    }
  }
  return $bundle_options;
}