You are here

public static function EntityBrowserElement::isEntityBrowserAvailable in Entity Browser 8

Same name and namespace in other branches
  1. 8.2 src/Element/EntityBrowserElement.php \Drupal\entity_browser\Element\EntityBrowserElement::isEntityBrowserAvailable()

Check whether entity browser should be available for selection of entities.

Parameters

string $selection_mode: Used selection mode.

int $cardinality: Used cardinality.

int $preselection_size: Preseletion size, if it's available.

Return value

bool Returns positive if entity browser can be used.

1 call to EntityBrowserElement::isEntityBrowserAvailable()
EntityReferenceBrowserWidget::formElement in src/Plugin/Field/FieldWidget/EntityReferenceBrowserWidget.php
Returns the form for a single field widget.

File

src/Element/EntityBrowserElement.php, line 125

Class

EntityBrowserElement
Provides an Entity Browser form element.

Namespace

Drupal\entity_browser\Element

Code

public static function isEntityBrowserAvailable($selection_mode, $cardinality, $preselection_size) {
  if ($selection_mode == static::SELECTION_MODE_EDIT) {
    return TRUE;
  }
  $cardinality_exceeded = $cardinality != static::CARDINALITY_UNLIMITED && $preselection_size >= $cardinality;
  return !$cardinality_exceeded;
}