You are here

public function HideOnRole::access in Field Formatter Condition 8

Access control function.

Parameters

array $build: The current build array.

string $field: The current field name.

array $settings: The current settings array.

Overrides FieldFormatterConditionBase::access

File

src/Plugin/Field/FieldFormatter/Condition/HideOnRole.php, line 49

Class

HideOnRole
The plugin for check empty fields.

Namespace

Drupal\fico\Plugin\Field\FieldFormatter\Condition

Code

public function access(&$build, $field, $settings) {
  if (array_intersect(\Drupal::currentUser()
    ->getRoles(), $settings['settings']['roles']) && (\Drupal::currentUser()
    ->id() != 1 || $settings['settings']['include_admin'] == 1)) {
    $build[$field]['#access'] = FALSE;
  }
}