You are here

function esi_block__set_esi_settings in ESI: Edge Side Includes 7.3

Configure the ESI settings for a particular block.

Parameters

String $module: Module implementing the block.

String $delta: The block's delta.

Boolean $esi_enabled: Set to TRUE if this block should be served by ESI.

Int $esi_ttl: Time-to-live: cache lifetime for this block when served by ESI.

2 calls to esi_block__set_esi_settings()
EsiBlockTest::testServeBlockByESI in modules/esi_block/esi_block.test
Test that saving the page will correctly configure the block in the DB.
esi_block_block_admin_configure_submit in modules/esi_block/esi_block.module
Submit handler for the block_admin_configure form.

File

modules/esi_block/esi_block.module, line 176
ESI handler for blocks.

Code

function esi_block__set_esi_settings($module, $delta, $esi_enabled, $esi_ttl) {
  $transaction = db_transaction();
  try {
    db_update('block')
      ->fields(array(
      'esi_enabled' => (int) $esi_enabled,
      'esi_ttl' => (int) $esi_ttl,
    ))
      ->condition('module', $module)
      ->condition('delta', $delta)
      ->execute();
  } catch (Exception $e) {
    $transaction
      ->rollback();
    watchdog_exception('ESI block', $e);
    throw $e;
  }
}