You are here

protected function InlineEntityFormBase::getTargetBundles in Inline Entity Form 8

Gets the target bundles for the current field.

Return value

string[] A list of bundles.

4 calls to InlineEntityFormBase::getTargetBundles()
InlineEntityFormBase::getCreateBundles in src/Plugin/Field/FieldWidget/InlineEntityFormBase.php
Gets the bundles for which the current user has create access.
InlineEntityFormBase::isTranslating in src/Plugin/Field/FieldWidget/InlineEntityFormBase.php
Determines whether there's a translation in progress.
InlineEntityFormComplex::determineBundle in src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php
Determines bundle to be used when creating entity.
InlineEntityFormComplex::formElement in src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php
Returns the form for a single field widget.

File

src/Plugin/Field/FieldWidget/InlineEntityFormBase.php, line 179

Class

InlineEntityFormBase
Inline entity form widget base class.

Namespace

Drupal\inline_entity_form\Plugin\Field\FieldWidget

Code

protected function getTargetBundles() {
  $settings = $this
    ->getFieldSettings();
  if (!empty($settings['handler_settings']['target_bundles'])) {
    $target_bundles = array_values($settings['handler_settings']['target_bundles']);

    // Filter out target bundles which no longer exist.
    $existing_bundles = array_keys($this->entityTypeBundleInfo
      ->getBundleInfo($settings['target_type']));
    $target_bundles = array_intersect($target_bundles, $existing_bundles);
  }
  else {

    // If no target bundles have been specified then all are available.
    $target_bundles = array_keys($this->entityTypeBundleInfo
      ->getBundleInfo($settings['target_type']));
  }
  return $target_bundles;
}