You are here

public function EntityBrowser::getFirstWidget in Entity Browser 8

Same name and namespace in other branches
  1. 8.2 src/Entity/EntityBrowser.php \Drupal\entity_browser\Entity\EntityBrowser::getFirstWidget()

Gets first widget based on weights.

Return value

string|null First widget instance ID or NULL if no widgets are available.

Overrides EntityBrowserInterface::getFirstWidget

File

src/Entity/EntityBrowser.php, line 306

Class

EntityBrowser
Defines an entity browser configuration entity.

Namespace

Drupal\entity_browser\Entity

Code

public function getFirstWidget() {
  $instance_ids = $this
    ->getWidgets()
    ->getInstanceIds();
  $instance_ids = array_filter($instance_ids, function ($id) {
    return $this
      ->getWidget($id)
      ->access()
      ->isAllowed();
  });
  if (empty($instance_ids)) {
    return NULL;
  }
  return reset($instance_ids);
}