public function HideOnPages::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/ HideOnPages.php, line 48
Class
- HideOnPages
- The plugin for check empty fields.
Namespace
Drupal\fico\Plugin\Field\FieldFormatter\ConditionCode
public function access(&$build, $field, $settings) {
$path = \Drupal::service('path.current')
->getPath();
$path = $path[0] == '/' ? substr($path, 1) : $path;
$page_match = \Drupal::service('path.matcher')
->matchPath($path, $settings['settings']['pages']);
$page_match = !($settings['settings']['visibility'] xor $page_match);
if ($page_match) {
$build[$field]['#access'] = FALSE;
}
}