You are here

function like_and_dislike_is_enabled in Like & Dislike 8

Returns a flag whether given entity is enabled for likes and dislikes.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity to check.

Return value

bool TRUE if it is enabled for displaying likes and dislikes. Otherwise, FALSE.

2 calls to like_and_dislike_is_enabled()
LikeAndDislike::render in src/Plugin/views/field/LikeAndDislike.php
Renders the field.
like_and_dislike_entity_view in ./like_and_dislike.module
Renders the like/dislike buttons if the user has permission to see it.

File

./like_and_dislike.module, line 41
This module provides 2 voting widgets: Like and Dislike.

Code

function like_and_dislike_is_enabled(EntityInterface $entity) {
  $enabled_entity_type = \Drupal::config('like_and_dislike.settings')
    ->get('enabled_types.' . $entity
    ->getEntityTypeId());
  if (is_null($enabled_entity_type)) {
    return FALSE;
  }

  // Do a bundle check for entities that support bundles.
  return !$entity
    ->getEntityType()
    ->hasKey('bundle') || in_array($entity
    ->bundle(), $enabled_entity_type);
}