4 changed files with 101 additions and 7 deletions
@ -0,0 +1,7 @@ |
|||||||
|
caption_linker.caption_linker_settings: |
||||||
|
title: 'Caption Linker settings' |
||||||
|
description: 'Configure Caption Linker.' |
||||||
|
parent: system.admin_config_system |
||||||
|
route_name: caption_linker.caption_linker_settings |
||||||
|
weight: 100 |
||||||
|
|
||||||
@ -0,0 +1,7 @@ |
|||||||
|
caption_linker.caption_linker_settings: |
||||||
|
path: '/admin/config/system/caption-linker-settings' |
||||||
|
defaults: |
||||||
|
_title: 'Caption Linker settings' |
||||||
|
_form: 'Drupal\caption_linker\Form\CaptionLinkerSettingsForm' |
||||||
|
requirements: |
||||||
|
_permission: 'administer site configuration' |
||||||
@ -0,0 +1,52 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
declare(strict_types=1); |
||||||
|
|
||||||
|
namespace Drupal\caption_linker\Form; |
||||||
|
|
||||||
|
use Drupal\Core\Form\ConfigFormBase; |
||||||
|
use Drupal\Core\Form\FormStateInterface; |
||||||
|
|
||||||
|
/** |
||||||
|
* Configure Caption Linker settings for this site. |
||||||
|
*/ |
||||||
|
final class CaptionLinkerSettingsForm extends ConfigFormBase { |
||||||
|
|
||||||
|
/** |
||||||
|
* {@inheritdoc} |
||||||
|
*/ |
||||||
|
public function getFormId(): string { |
||||||
|
return 'caption_linker_settings_form'; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* {@inheritdoc} |
||||||
|
*/ |
||||||
|
protected function getEditableConfigNames(): array { |
||||||
|
return ['caption_linker.settings']; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* {@inheritdoc} |
||||||
|
*/ |
||||||
|
public function buildForm(array $form, FormStateInterface $form_state) { |
||||||
|
$config = $this->config('caption_linker.settings'); |
||||||
|
$use_hook = $config->get('use_hook'); |
||||||
|
$form['use_hook'] = [ |
||||||
|
'#type' => 'checkbox', |
||||||
|
'#title' => $this->t('Automatically link captions to Audio or Video Media'), |
||||||
|
'#description' => $this->t("If checked, a media tagged <strong>Transcript</strong> will be automatically linked to an AblePlayer Audio or Video Media."), |
||||||
|
'#default_value' => $use_hook, |
||||||
|
]; |
||||||
|
|
||||||
|
return parent::buildForm($form, $form_state); |
||||||
|
} |
||||||
|
|
||||||
|
public function submitForm(array &$form, FormStateInterface $form_state) { |
||||||
|
$use_hook = $form_state->getValue('use_hook'); |
||||||
|
$this->config('caption_linker.settings') |
||||||
|
->set('use_hook', $use_hook) |
||||||
|
->save(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
Loading…
Reference in new issue