You are here

function authcache_block_authcache_p13n_fragment in Authenticated User Page Caching (Authcache) 7.2

Implements hook_authcache_p13n_fragment().

File

modules/authcache_block/authcache_block.module, line 10
Authcache support for block module.

Code

function authcache_block_authcache_p13n_fragment() {
  $result = db_select('block', 'b')
    ->fields('b')
    ->execute();
  $blocks = $result
    ->fetchAllAssoc('bid');
  $fragments = array();
  foreach ($blocks as $block) {
    $block_id = "{$block->module}-{$block->delta}";
    $config = variable_get('authcache_block-' . $block_id);
    if (!empty($config['status'])) {
      $fragment_id = 'block/' . $block_id;
      $fragments[$fragment_id] = array(
        'fragment' => array(
          '#class' => 'AuthcacheBlockFragment',
          '#arguments' => array(
            $block_id,
            $block->module,
            $block->delta,
          ),
        ),
        'bootstrap phase' => DRUPAL_BOOTSTRAP_FULL,
        'cache maxage' => authcache_p13n_config_cache_maxage($config),
        'cache granularity' => authcache_p13n_config_cache_granularity($config),
        'admin entry object' => array(
          '#class' => 'AuthcacheBlockAdminEntry',
          '#arguments' => array(
            $block_id,
            $config,
            '@admin entry',
          ),
        ),
      );
    }
  }

  // Garbage collect spurious configuration.
  authcache_block_variables_gc();
  return $fragments;
}