You are here

public function DsFieldBase::isAllowed in Display Suite 8.2

Same name and namespace in other branches
  1. 8.4 src/Plugin/DsField/DsFieldBase.php \Drupal\ds\Plugin\DsField\DsFieldBase::isAllowed()
  2. 8.3 src/Plugin/DsField/DsFieldBase.php \Drupal\ds\Plugin\DsField\DsFieldBase::isAllowed()

Returns if the field is allowed on the field UI screen.

Overrides DsFieldInterface::isAllowed

4 methods override DsFieldBase::isAllowed()
BookNavigation::isAllowed in src/Plugin/DsField/Book/BookNavigation.php
Returns if the field is allowed on the field UI screen.
ExampleField::isAllowed in drush/ExampleField.php
Returns if the field is allowed on the field UI screen.
SwitchField::isAllowed in modules/ds_extras/src/Plugin/DsField/SwitchField.php
Returns if the field is allowed on the field UI screen.
UserSignature::isAllowed in src/Plugin/DsField/User/UserSignature.php
Returns if the field is allowed on the field UI screen.

File

src/Plugin/DsField/DsFieldBase.php, line 86

Class

DsFieldBase
Base class for all the ds plugins.

Namespace

Drupal\ds\Plugin\DsField

Code

public function isAllowed() {
  $definition = $this
    ->getPluginDefinition();
  if (!isset($definition['ui_limit'])) {
    return TRUE;
  }
  $limits = $definition['ui_limit'];
  foreach ($limits as $limit) {
    if (strpos($limit, '|') !== FALSE) {
      list($bundle_limit, $view_mode_limit) = explode('|', $limit);
      if (($bundle_limit == $this
        ->bundle() || $bundle_limit == '*') && ($view_mode_limit == $this
        ->viewMode() || $view_mode_limit == '*')) {
        return TRUE;
      }
    }
  }

  // When the current bundle view_mode combination is not allowed we shouldn't
  // show the field.
  return FALSE;
}