public function VotingApiReactionManager::getIcon in Voting API Reaction 8
Return URL to reaction icon.
Parameters
\Drupal\votingapi\Entity\VoteType $entity: Current vote entity.
bool $default: Default icon is used.
Return value
string Reaction icon url.
1 call to VotingApiReactionManager::getIcon()
- VotingApiReactionManager::getReactions in src/
VotingApiReactionManager.php - Return rendered list of active reactions.
File
- src/
VotingApiReactionManager.php, line 320
Class
- VotingApiReactionManager
- Manages reactions through Voting API entities.
Namespace
Drupal\votingapi_reactionCode
public function getIcon(VoteType $entity, &$default = TRUE) {
$path = implode('/', [
drupal_get_path('module', 'votingapi_reaction'),
'svg',
'',
]);
// Fallback icon.
$url = $path . 'reaction_noicon.svg';
// User defined icon.
$icon = $entity
->getThirdPartySetting('votingapi_reaction', 'icon');
if ($icon && ($file = $this->fileStorage
->load($icon))) {
$url = $file
->getFileUri();
$default = FALSE;
}
elseif (file_exists(DRUPAL_ROOT . "/{$path}" . $entity
->id() . '.svg')) {
$url = $path . $entity
->id() . '.svg';
}
return file_create_url($url);
}