public function HideIfAuthor::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/ HideIfAuthor.php, line 45
Class
- HideIfAuthor
- The plugin for check empty fields.
Namespace
Drupal\fico\Plugin\Field\FieldFormatter\ConditionCode
public function access(&$build, $field, $settings) {
$entity = $this
->getEntity($build);
if (!$entity) {
$build[$field]['#access'] = FALSE;
return;
}
if (!$settings['settings']['author'] && $entity
->getOwnerId() == 0 || $entity
->getOwnerId() == $settings['settings']['author']) {
$build[$field]['#access'] = FALSE;
}
}