function votingapi_widgets_theme_suggestions_alter in Votingapi Widgets 8
Implements hook_theme_suggestions_alter().
File
- ./
votingapi_widgets.module, line 77 - Contains votingapi_widgets.module..
Code
function votingapi_widgets_theme_suggestions_alter(array &$suggestions, array $variables, $hook) {
if ($hook == 'votingapi_widgets_summary') {
$entity = $variables['vote'];
$content = \Drupal::service('entity_type.manager')
->getStorage($entity
->getVotedEntityType())
->load($entity
->getVotedEntityId());
$fieldSettings = FieldConfig::loadByName($content
->getEntityTypeId(), $content
->bundle(), $variables['field_name']);
$plugin = $fieldSettings
->getSetting('vote_plugin');
$suggestions[] = $hook . '__' . $plugin;
$suggestions[] = $hook . '__' . $plugin . '__' . $entity->field_name->value;
$suggestions[] = $hook . '__' . $plugin . '__' . $content
->getEntityTypeId();
$suggestions[] = $hook . '__' . $plugin . '__' . $content
->getEntityTypeId() . '__' . $content
->bundle() . '__' . $entity->field_name->value;
$suggestions[] = $hook . '__' . $plugin . '__' . $content
->getEntityTypeId() . '__' . $content
->bundle();
}
}