You are here

public static function EntityHelper::isPubliclyVisible in Helper 7

Deprecated

Use the entity_is_public module instead.

File

lib/EntityHelper.php, line 496

Class

EntityHelper

Code

public static function isPubliclyVisible($entity_type, $entity, array $options = array()) {
  $options += array(
    'needs alias' => FALSE,
  );
  $uri = entity_uri($entity_type, $entity);
  if (empty($uri['path'])) {
    return FALSE;
  }
  elseif ($options['needs alias'] && !drupal_lookup_path('alias', $uri['path'], NULL)) {
    return FALSE;
  }
  elseif (module_exists('rabbit_hole') && rabbit_hole_get_action($entity_type, $entity) !== RABBIT_HOLE_DISPLAY_CONTENT) {
    return FALSE;
  }
  else {
    return entity_access('view', $entity_type, $entity, drupal_anonymous_user());
  }
}