public function BlockVisibilityGroupDeleteForm::setBlocksGroup in Block Visibility Groups 8
Set the visibility group for blocks.
Parameters
array $blocks: The blocks.
string $group_id: The group id.
1 call to BlockVisibilityGroupDeleteForm::setBlocksGroup()
- BlockVisibilityGroupDeleteForm::submitForm in src/
Form/ BlockVisibilityGroupDeleteForm.php - This is the default entity object builder function. It is called before any other submit handler to build the new entity object to be used by the following submit handlers. At this point of the form workflow the entity is validated and the form state…
File
- src/
Form/ BlockVisibilityGroupDeleteForm.php, line 82
Class
- BlockVisibilityGroupDeleteForm
- Builds the form to delete Block Visibility Group entities.
Namespace
Drupal\block_visibility_groups\FormCode
public function setBlocksGroup(array $blocks, $group_id = '') {
/** @var \Drupal\block\Entity\Block $block */
foreach ($blocks as $block) {
$config = $block
->getVisibilityCondition('condition_group')
->getConfiguration();
$config['block_visibility_group'] = $group_id;
$block
->setVisibilityConfig('condition_group', $config);
$block
->save();
}
}