Basic example

Last updated on
9 October 2019

INPUT (example)

REPLACE INPUT WITH YOUR OWN CONFIG OBJECT.

Configuration object

filter.format.full_html

Parent keys

All parent keys from highest to the one above the snippet (here just one):

  • filters

YAML snippet

  filter_caption:
    id: filter_caption
    provider: filter
    status: true
    weight: 9
    settings: {  }
  filter_htmlcorrector:
    id: filter_htmlcorrector
    provider: filter
    status: true
    weight: 10
    settings: {  }

OUTPUT (PHP snippet to copy and paste)

<?php
/**
 * @file
 * Set part of a configuration object in the database.
 *
 * Remember to export the configuration to coresponding YAML file and commit.
 * Generated with https://drupal.org/project/yaml2php.
 */
$filter_caption = [
  'id' => 'filter_caption',
  'provider' => 'filter',
  'status' => TRUE,
  'weight' => 9,
  'settings' => [],
];
\Drupal::configFactory()->getEditable('filter.format.full_html')
  ->set('filters.filter_caption', $filter_caption)
  ->save();

$filter_htmlcorrector = [
  'id' => 'filter_htmlcorrector',
  'provider' => 'filter',
  'status' => TRUE,
  'weight' => 10,
  'settings' => [],
];
\Drupal::configFactory()->getEditable('filter.format.full_html')
  ->set('filters.filter_htmlcorrector', $filter_htmlcorrector)
  ->save();

Help improve this page

Page status: No known problems

You can: