private function MediaSettingsForm::providerFormContainer in Cookie Content Blocker 8
Create a container to configure provider settings.
Parameters
string $provider: The name of the provider.
Return value
array The event form container.
1 call to MediaSettingsForm::providerFormContainer()
- MediaSettingsForm::buildForm in modules/
cookie_content_blocker_media/ src/ Form/ MediaSettingsForm.php - Form constructor.
File
- modules/
cookie_content_blocker_media/ src/ Form/ MediaSettingsForm.php, line 110
Class
- MediaSettingsForm
- Form builder to manage settings for Cookie content blocker - Media.
Namespace
Drupal\cookie_content_blocker_media\FormCode
private function providerFormContainer(string $provider) : array {
$config = $this
->config('cookie_content_blocker_media.settings')
->get("providers.{$provider}");
$container = [
'#type' => 'details',
'#title' => $this
->t('Settings for %provider media', [
'%provider' => $provider,
]),
'#tree' => TRUE,
];
$container['blocked'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Block %provider media', [
'%provider' => $provider,
]),
'#description' => $this
->t('Enable blocking of all %provider media until consent is given.', [
'%provider' => $provider,
]),
'#default_value' => $config['blocked'] ?? FALSE,
];
$container['show_preview'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Show a preview for blocked content'),
'#default_value' => $config['show_preview'] ?? FALSE,
];
$container['preview_style'] = [
'#type' => 'select',
'#title' => $this
->t('Choose an image style to use for the preview.'),
'#options' => image_style_options(FALSE),
'#default_value' => $config['preview_style'] ?? 'blocked_media_teaser',
'#states' => [
'visible' => [
':input[name="providers[' . $provider . '][show_preview]"]' => [
'checked' => TRUE,
],
],
],
];
$container['blocked_message'] = [
'#type' => 'text_format',
'#title' => $this
->t('Message for blocked %provider media', [
'%provider' => $provider,
]),
'#description' => $this
->t('When %provider media is blocked and a message is shown, this message will be shown.', [
'%provider' => $provider,
]),
'#default_value' => $config['blocked_message']['value'] ?? $this
->t('You have not yet given permission to place the required cookies. Accept the required cookies to view this content.'),
'#format' => $config['blocked_message']['format'] ?? NULL,
'#states' => [
'visible' => [
':input[name="providers[' . $provider . '][blocked]"]' => [
'checked' => TRUE,
],
],
],
];
return $container;
}