You are here

protected function EntityFormProxy::getAllowedBundles in Lightning Media 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/EntityBrowser/Widget/EntityFormProxy.php \Drupal\lightning_media\Plugin\EntityBrowser\Widget\EntityFormProxy::getAllowedBundles()

Returns the bundles that this widget may use.

Parameters

\Drupal\Core\Form\FormStateInterface $form_state: The current form state.

Return value

string[] The bundles that this widget may use. If all bundles may be used, the returned array will be empty.

3 calls to EntityFormProxy::getAllowedBundles()
EntityFormProxy::getForm in src/Plugin/EntityBrowser/Widget/EntityFormProxy.php
EntityFormProxy::validate in src/Plugin/EntityBrowser/Widget/EntityFormProxy.php
FileUpload::getForm in src/Plugin/EntityBrowser/Widget/FileUpload.php

File

src/Plugin/EntityBrowser/Widget/EntityFormProxy.php, line 75

Class

EntityFormProxy
Base class for EB widgets which wrap around an (inline) entity form.

Namespace

Drupal\lightning_media\Plugin\EntityBrowser\Widget

Code

protected function getAllowedBundles(FormStateInterface $form_state) {
  $target_bundles = (array) $form_state
    ->get([
    'entity_browser',
    'widget_context',
    'target_bundles',
  ]);
  if ($target_bundles) {
    return $target_bundles;
  }
  $bundle = $form_state
    ->getValue('bundle');
  if ($bundle) {
    return [
      $bundle,
    ];
  }
  return [];
}