function blocache_block_form_builder in Blocache (Block Cache Control) 8
Entity builder function for the block form.
1 string reference to 'blocache_block_form_builder'
- blocache_form_block_form_alter in ./
blocache.module - Implements hook_form_FORM_ID_alter() for block_form.
File
- ./
blocache.module, line 293 - Provides a structure for block cache control.
Code
function blocache_block_form_builder($entity_type, BlockInterface $block, &$form, FormStateInterface $form_state) {
$blocache = Drupal::service('blocache');
$blocache_metadata = Drupal::service('blocache.metadata');
$blocache_metadata
->setBlock($block);
$values = $form_state
->getValue('blocache');
if ($values['overridden'] === 1) {
$tabs = $values['tabs'];
$max_age = (int) $tabs['max-age']['value'];
$contexts = $blocache
->prepareContextsToStorage($tabs['contexts']['value']);
$tags = $tabs['tags']['value'];
$blocache_metadata
->setOverrides($max_age, $contexts, $tags);
}
else {
$blocache_metadata
->unsetOverrides();
}
}