You are here

public static function CacheFragmentController::resourceIdFromHash in RESTful 7.2

Get the resource ID for the selected hash.

Parameters

string $hash: The unique hash for the cache fragments.

Return value

string The resource ID.

2 calls to CacheFragmentController::resourceIdFromHash()
restful_entity_clear_render_cache in ./restful.entity.inc
Delete the scheduled fragments and caches on shutdown.
_restful_entity_clear_all_resources in ./restful.entity.inc
Clear the cache back ends for the given hash.

File

src/RenderCache/Entity/CacheFragmentController.php, line 207
Contains \Drupal\restful\RenderCache\Entity\CacheFragmentController.

Class

CacheFragmentController
Class CacheFragmentController.

Namespace

Drupal\restful\RenderCache\Entity

Code

public static function resourceIdFromHash($hash) {
  $query = new \EntityFieldQuery();
  $results = $query
    ->entityCondition('entity_type', static::ENTITY_TYPE)
    ->propertyCondition('type', 'resource')
    ->propertyCondition('hash', $hash)
    ->range(0, 1)
    ->execute();
  if (empty($results[static::ENTITY_TYPE])) {
    return NULL;
  }
  $cache_fragment = entity_load_single(static::ENTITY_TYPE, key($results[static::ENTITY_TYPE]));
  $pos = strpos($cache_fragment->value, CacheDecoratedResource::CACHE_PAIR_SEPARATOR);
  return $pos === FALSE ? $cache_fragment->value : substr($cache_fragment->value, 0, $pos);
}