function fico_field_formatter_settings_summary_alter in Field Formatter Condition 8
Implements hook_field_formatter_settings_summary_alter().
File
- ./
fico.module, line 232 - Contains fico.module.
Code
function fico_field_formatter_settings_summary_alter(&$summary, $context) {
$fico_plugin_manager = Drupal::service('plugin.manager.field_formatter_condition');
$conditions = [];
foreach ($fico_plugin_manager
->getPlugins() as $plug) {
$conditions[$plug['id']] = $plug['label'];
}
$settings = $context['formatter']
->getThirdPartySetting('fico', 'fico');
$settings['view_mode'] = $context['view_mode'];
if (is_object($context['field_definition']) && method_exists($context['field_definition'], 'get')) {
$settings['field_type'] = $context['field_definition']
->get('field_type');
$settings['field_name'] = $context['field_definition']
->get('field_name');
$settings['entity_type'] = $context['field_definition']
->get('entity_type');
$settings['bundle'] = $context['field_definition']
->get('bundle');
}
if (!empty($settings['condition'])) {
$formatterPlugin = $fico_plugin_manager
->createInstance($settings['condition']);
$summary[] = $formatterPlugin
->summary($settings);
}
else {
$summary[] = t("Condition: %condition", [
"%condition" => t('not set'),
]);
}
}