Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add auto heading id filter to the wysiwyg format on install. #143

Merged
merged 7 commits into from
Feb 27, 2024
20 changes: 20 additions & 0 deletions localgov_publications.install
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,37 @@
* Install, update and uninstall functions for the LocalGov Publications module.
*/

use Drupal\filter\Entity\FilterFormat;

/**
* Implements hook_install().
*/
function localgov_publications_install() {

// Add our localgov_publication_page content type to
// book.settings.allowed_types. This lets editors create publication pages.
$config = \Drupal::configFactory()->getEditable('book.settings');
$allowed_types = $config->get('allowed_types');
$allowed_types[] = 'localgov_publication_page';
$config->set('allowed_types', $allowed_types);
$config->save();

// Add our localgov-publication-cover-page-alias to
// pathauto.settings.safe_tokens. This prevents double escaping in the
// resulting URL.
$path_auto_config = \Drupal::configFactory()->getEditable('pathauto.settings');
$safe_tokens = $path_auto_config->get('safe_tokens');
$safe_tokens[] = 'localgov-publication-cover-page-alias';
$path_auto_config->set('safe_tokens', $safe_tokens)->save();

// Add heading_id_filter from the auto_heading_ids module to the wysiwyg
// filter format. This is required for the ToC block to work consistently.
/** @var \Drupal\filter\Entity\FilterFormat $wysiwygFormat */
$wysiwygFormat = FilterFormat::load('wysiwyg');
if ($wysiwygFormat) {
rupertj marked this conversation as resolved.
Show resolved Hide resolved
$wysiwygFormat->setFilterConfig('heading_id_filter', [
'status' => TRUE,
]);
$wysiwygFormat->save();
}
}
Loading