book.module 21.3 KB
Newer Older
Dries's avatar
 
Dries committed
1 2
<?php

Dries's avatar
 
Dries committed
3 4
/**
 * @file
5
 * Allows users to create and organize related content in an outline.
Dries's avatar
 
Dries committed
6 7
 */

8
use Drupal\book\BookManagerInterface;
9
use Drupal\Component\Utility\String;
10
use Drupal\Core\Entity\EntityInterface;
11
use Drupal\Core\Render\Element;
12
use Drupal\node\NodeInterface;
13
use Drupal\node\NodeTypeInterface;
14
use Drupal\Core\Language\Language;
15
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
16
use Drupal\Core\Template\Attribute;
17

18
/**
19
 * Implements hook_help().
20 21 22 23 24
 */
function book_help($path, $arg) {
  switch ($path) {
    case 'admin/help#book':
      $output = '<h3>' . t('About') . '</h3>';
25
      $output .= '<p>' . t('The Book module is used for creating structured, multi-page content, such as site resource guides, manuals, and wikis. It allows you to create content that has chapters, sections, subsections, or any similarly-tiered structure. For more information, see the <a href="!book">online documentation for the Book module</a>.', array('!book' => 'https://drupal.org/documentation/modules/book')) . '</p>';
26 27 28
      $output .= '<h3>' . t('Uses') . '</h3>';
      $output .= '<dl>';
      $output .= '<dt>' . t('Adding and managing book content') . '</dt>';
29
      $output .= '<dd>' . t('You can assign separate permissions for <em>creating new books</em> as well as <em>creating</em>, <em>editing</em> and <em>deleting</em> book content. Users with the <em>Administer book outlines</em> permission can add <em>any</em> type of content to a book by selecting the appropriate book outline while editing the content. They can also view a list of all books, and edit and rearrange section titles on the <a href="!admin-book">Book administration page</a>.', array('!admin-book' => \Drupal::url('book.admin'))) . '</dd>';
30
      $output .= '<dt>' . t('Book navigation') . '</dt>';
31
      $output .= '<dd>' . t("Book pages have a default book-specific navigation block. This navigation block contains links that lead to the previous and next pages in the book, and to the level above the current page in the book's structure. This block can be enabled on the <a href='!admin-block'>Blocks administration page</a>. For book pages to show up in the book navigation, they must be added to a book outline.", array('!admin-block' => \Drupal::url('block.admin_display'))) . '</dd>';
32
      $output .= '<dt>' . t('Collaboration') . '</dt>';
33
      $output .= '<dd>' . t('Books can be created collaboratively, as they allow users with appropriate permissions to add pages into existing books, and add those pages to a custom table of contents.') . '</dd>';
34
      $output .= '<dt>' . t('Printing books') . '</dt>';
35
      $output .= '<dd>' . t("Users with the <em>View printer-friendly books</em> permission can select the <em>printer-friendly version</em> link visible at the bottom of a book page's content to generate a printer-friendly display of the page and all of its subsections.") . '</dd>';
36 37
      $output .= '</dl>';
      return $output;
38
    case 'admin/structure/book':
39 40
      return '<p>' . t('The book module offers a means to organize a collection of related content pages, collectively known as a book. When viewed, this content automatically displays links to adjacent book pages, providing a simple navigation system for creating and reviewing structured content.') . '</p>';
    case 'node/%/outline':
41
      return '<p>' . t('The outline feature allows you to include pages in the <a href="!book">Book hierarchy</a>, as well as move them within the hierarchy or to <a href="!book-admin">reorder an entire book</a>.', array('!book' => \Drupal::url('book.render'), '!book-admin' => \Drupal::url('book.admin'))) . '</p>';
42 43 44
  }
}

45
/**
46
 * Implements hook_theme().
47 48 49 50
 */
function book_theme() {
  return array(
    'book_navigation' => array(
51
      'variables' => array('book_link' => NULL),
52
      'template' => 'book-navigation',
53
    ),
54 55 56 57
    'book_tree' => array(
      'render element' => 'tree',
      'template' => 'book-tree',
    ),
58 59 60
    'book_link' => array(
      'render element' => 'element',
    ),
61
    'book_export_html' => array(
62
      'variables' => array('title' => NULL, 'contents' => NULL, 'depth' => NULL),
63
      'template' => 'book-export-html',
64 65
    ),
    'book_admin_table' => array(
66
      'render element' => 'form',
67
      'file' => 'book.admin.inc',
68
    ),
Dries's avatar
Dries committed
69
    'book_all_books_block' => array(
70
      'render element' => 'book_menus',
71 72 73
      'template' => 'book-all-books-block',
    ),
    'book_node_export_html' => array(
74
      'variables' => array('node' => NULL, 'children' => NULL),
75
      'template' => 'book-node-export-html',
Dries's avatar
Dries committed
76
    ),
77 78 79
  );
}

80
/**
81
 * Implements hook_permission().
82
 */
83
function book_permission() {
84
  return array(
85 86 87 88 89 90 91
    'administer book outlines' => array(
      'title' => t('Administer book outlines'),
    ),
    'create new books' => array(
      'title' => t('Create new books'),
    ),
    'add content to books' => array(
92
      'title' => t('Add content and child pages to books'),
93 94
    ),
    'access printer-friendly version' => array(
95
      'title' => t('View printer-friendly books'),
96 97
      'description' => t('View a book page and all of its sub-pages as a single document for ease of printing. Can be performance heavy.'),
    ),
98
  );
Dries's avatar
 
Dries committed
99 100
}

101
/**
102
 * Implements hook_entity_type_build().
103
 */
104 105 106
function book_entity_type_build(array &$entity_types) {
  /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
  $entity_types['node']
107 108 109
    ->setFormClass('book_outline', 'Drupal\book\Form\BookOutlineForm')
    ->setLinkTemplate('book-outline-form', 'book.outline')
    ->setLinkTemplate('book-remove-form', 'book.remove');
110 111
}

Dries's avatar
 
Dries committed
112
/**
113
 * Implements hook_node_links_alter().
Dries's avatar
 
Dries committed
114
 */
115 116 117 118 119 120 121 122 123 124 125 126
function book_node_links_alter(array &$node_links, NodeInterface $node, array &$context) {
  if ($context['view_mode'] != 'rss') {
    $account = \Drupal::currentUser();

    if (isset($node->book['depth'])) {
      if ($context['view_mode'] == 'full' && node_is_page($node)) {
        $child_type = \Drupal::config('book.settings')->get('child_type');
        $access_controller = \Drupal::entityManager()->getAccessController('node');
        if (($account->hasPermission('add content to books') || $account->hasPermission('administer book outlines')) && $access_controller->createAccess($child_type) && $node->isPublished() && $node->book['depth'] < MENU_MAX_DEPTH) {
          $links['book_add_child'] = array(
            'title' => t('Add child page'),
            'href' => 'node/add/' . $child_type,
127
            'query' => array('parent' => $node->id()),
128 129 130 131 132 133 134 135 136 137
          );
        }

        if ($account->hasPermission('access printer-friendly version')) {
          $links['book_printer'] = array(
            'title' => t('Printer-friendly version'),
            'href' => 'book/export/html/' . $node->id(),
            'attributes' => array('title' => t('Show a printer-friendly version of this book page and its sub-pages.'))
          );
        }
138
      }
Dries's avatar
 
Dries committed
139
    }
140

141 142 143 144 145 146 147
    if (!empty($links)) {
      $node_links['book'] = array(
        '#theme' => 'links__node__book',
        '#links' => $links,
        '#attributes' => array('class' => array('links', 'inline')),
      );
    }
148
  }
Dries's avatar
 
Dries committed
149 150
}

Dries's avatar
Dries committed
151
/**
152
 * Implements hook_form_BASE_FORM_ID_alter() for node_form().
153
 *
154
 * Adds the book form element to the node form.
155 156
 *
 * @see book_pick_book_nojs_submit()
Dries's avatar
Dries committed
157
 */
158
function book_form_node_form_alter(&$form, &$form_state, $form_id) {
159
  $node = $form_state['controller']->getEntity();
160
  $account = \Drupal::currentUser();
161
  $access = $account->hasPermission('administer book outlines');
162
  if (!$access) {
163
    if ($account->hasPermission('add content to books') && ((!empty($node->book['bid']) && !$node->isNew()) || book_type_is_allowed($node->getType()))) {
164 165
      // Already in the book hierarchy, or this node type is allowed.
      $access = TRUE;
Dries's avatar
Dries committed
166
    }
167
  }
Dries's avatar
Dries committed
168

169
  if ($access) {
170 171
    $collapsed = !($node->isNew() && !empty($node->book['pid']));
    $form = \Drupal::service('book.manager')->addFormElements($form, $form_state, $node, $account, $collapsed);
172
    // Since the "Book" dropdown can't trigger a form submission when
173
    // JavaScript is disabled, add a submit button to do that. book.admin.css hides
174 175 176 177 178 179
    // this button when JavaScript is enabled.
    $form['book']['pick-book'] = array(
      '#type' => 'submit',
      '#value' => t('Change book (update list of parents)'),
      '#submit' => array('book_pick_book_nojs_submit'),
      '#weight' => 20,
180
      '#attached' => array(
181
        'css' => array(drupal_get_path('module', 'book') . '/css/book.admin.css'),
182
      ),
183
    );
184
    $form['#entity_builders'][] = 'book_node_builder';
185
  }
Dries's avatar
Dries committed
186
}
187

188 189 190 191 192
/**
 * Entity form builder to add the book information to the node.
 *
 * @todo: Remove this in favor of an entity field.
 */
193
function book_node_builder($entity_type, NodeInterface $entity, &$form, &$form_state) {
194
  $entity->book = $form_state['values']['book'];
195 196 197 198 199

  // Always save a revision for non-administrators.
  if (!empty($entity->book['bid']) && !\Drupal::currentUser()->hasPermission('administer nodes')) {
    $entity->setNewRevision();
  }
200 201
}

202
/**
203
 * Form submission handler for node_form().
204 205 206 207 208
 *
 * This handler is run when JavaScript is disabled. It triggers the form to
 * rebuild so that the "Parent item" options are changed to reflect the newly
 * selected book. When JavaScript is enabled, the submit button that triggers
 * this handler is hidden, and the "Book" dropdown directly triggers the
209
 * book_form_update() Ajax callback instead.
210 211
 *
 * @see book_form_update()
212
 * @see book_form_node_form_alter()
213 214
 */
function book_pick_book_nojs_submit($form, &$form_state) {
215
  $node = $form_state['controller']->getEntity();
216
  $node->book = $form_state['values']['book'];
217 218 219
  $form_state['rebuild'] = TRUE;
}

220 221 222
/**
 * Renders a new parent page select element when the book selection changes.
 *
223
 * This function is called via Ajax when the selected book is changed on a node
224 225 226 227 228 229
 * or book outline form.
 *
 * @return
 *   The rendered parent page select element.
 */
function book_form_update($form, $form_state) {
230
  return $form['book']['pid'];
231 232
}

233
/**
234
 * Implements hook_node_load().
235
 */
236
function book_node_load($nodes) {
237 238 239 240
  /** @var \Drupal\book\BookManagerInterface $book_manager */
  $book_manager = \Drupal::service('book.manager');
  $links = $book_manager->loadBookLinks(array_keys($nodes), FALSE);
  foreach ($links as $record) {
241
    $nodes[$record['nid']]->book = $record;
242 243
    $nodes[$record['nid']]->book['link_path'] = 'node/' . $record['nid'];
    $nodes[$record['nid']]->book['link_title'] = $nodes[$record['nid']]->label();
244 245
  }
}
246

247
/**
248
 * Implements hook_node_view().
249
 */
250
function book_node_view(EntityInterface $node, EntityViewDisplayInterface $display, $view_mode) {
251
  if ($view_mode == 'full') {
252
    if (!empty($node->book['bid']) && empty($node->in_preview)) {
253
      $book_navigation = array( '#theme' => 'book_navigation', '#book_link' => $node->book);
254
      $node->content['book_navigation'] = array(
255
        '#markup' => drupal_render($book_navigation),
256
        '#weight' => 100,
257 258 259 260 261
        '#attached' => array(
          'css' => array(
            drupal_get_path('module', 'book') . '/css/book.theme.css',
          ),
        ),
262 263 264
      );
    }
  }
265 266
}

267
/**
268
 * Implements hook_node_presave().
269
 */
270
function book_node_presave(EntityInterface $node) {
271
  // Make sure a new node gets a new menu link.
272
  if ($node->isNew()) {
273
    $node->book['nid'] = NULL;
274 275
  }
}
276

277
/**
278
 * Implements hook_node_insert().
279
 */
280
function book_node_insert(EntityInterface $node) {
281
  /** @var \Drupal\book\BookManagerInterface $book_manager */
282
  $book_manager = \Drupal::service('book.manager');
283
  $book_manager->updateOutline($node);
284
}
285

286
/**
287
 * Implements hook_node_update().
288
 */
289
function book_node_update(EntityInterface $node) {
290
  /** @var \Drupal\book\BookManagerInterface $book_manager */
291
  $book_manager = \Drupal::service('book.manager');
292
  $book_manager->updateOutline($node);
293
}
294

295
/**
296
 * Implements hook_node_predelete().
297
 */
298
function book_node_predelete(EntityInterface $node) {
299
  if (!empty($node->book['bid'])) {
300 301 302
    /** @var \Drupal\book\BookManagerInterface $book_manager */
    $book_manager = \Drupal::service('book.manager');
    $book_manager->deleteFromBook($node->book['nid']);
303 304 305 306
  }
}

/**
307
 * Implements hook_node_prepare_form().
308
 */
309
function book_node_prepare_form(NodeInterface $node, $operation, array &$form_state) {
310
  /** @var \Drupal\book\BookManagerInterface $book_manager */
311
  $book_manager = \Drupal::service('book.manager');
312

313
  // Prepare defaults for the add/edit form.
314
  $account = \Drupal::currentUser();
315
  if (empty($node->book) && ($account->hasPermission('add content to books') || $account->hasPermission('administer book outlines'))) {
316 317
    $node->book = array();

318
    $query = \Drupal::request()->query;
319
    if ($node->isNew() && !is_null($query->get('parent')) && is_numeric($query->get('parent'))) {
320
      // Handle "Add child page" links:
321
      $parent = $book_manager->loadBookLink($query->get('parent'), TRUE);
322 323 324

      if ($parent && $parent['access']) {
        $node->book['bid'] = $parent['bid'];
325
        $node->book['pid'] = $parent['nid'];
326
      }
327 328
    }
    // Set defaults.
329 330
    $node_ref = !$node->isNew() ? $node->id() : 'new';
    $node->book += $book_manager->getLinkDefaults($node_ref);
331 332 333 334 335 336 337 338
  }
  else {
    if (isset($node->book['bid']) && !isset($node->book['original_bid'])) {
      $node->book['original_bid'] = $node->book['bid'];
    }
  }
  // Find the depth limit for the parent select.
  if (isset($node->book['bid']) && !isset($node->book['parent_depth_limit'])) {
339
    $node->book['parent_depth_limit'] = $book_manager->getParentDepthLimit($node->book);
Dries's avatar
Dries committed
340 341 342 343
  }
}

/**
344
 * Implements hook_form_FORM_ID_alter() for node_delete_confirm().
345 346 347 348
 *
 * Alters the confirm form for a single node deletion.
 *
 * @see node_delete_confirm()
Dries's avatar
Dries committed
349 350 351 352 353 354
 */
function book_form_node_delete_confirm_alter(&$form, $form_state) {
  $node = node_load($form['nid']['#value']);

  if (isset($node->book) && $node->book['has_children']) {
    $form['book_warning'] = array(
355
      '#markup' => '<p>' . t('%title is part of a book outline, and has associated child pages. If you proceed with deletion, the child pages will be relocated automatically.', array('%title' => $node->label())) . '</p>',
Dries's avatar
Dries committed
356 357
      '#weight' => -10,
    );
Dries's avatar
 
Dries committed
358
  }
Dries's avatar
 
Dries committed
359
}
Dries's avatar
 
Dries committed
360

361
/**
362
 * Implements hook_preprocess_HOOK() for block templates.
363 364
 */
function book_preprocess_block(&$variables) {
365
  if ($variables['configuration']['provider'] == 'book') {
366
    $variables['attributes']['role'] = 'navigation';
367 368 369
  }
}

370
/**
371 372 373
 * Prepares variables for book listing block templates.
 *
 * Default template: book-all-books-block.html.twig.
374
 *
375 376 377
 * All non-renderable elements are removed so that the template has full access
 * to the structured data but can also simply iterate over all elements and
 * render them (as in the default template).
378
 *
379 380
 * @param array $variables
 *   An associative array containing the following key:
381 382
 *   - book_menus: An associative array containing renderable menu links for all
 *     book menus.
383 384 385 386 387
 */
function template_preprocess_book_all_books_block(&$variables) {
  // Remove all non-renderable elements.
  $elements = $variables['book_menus'];
  $variables['book_menus'] = array();
388
  foreach (Element::children($elements) as $index) {
389 390 391 392
    $variables['book_menus'][$index] = $elements[$index];
  }
}

Dries's avatar
Dries committed
393
/**
394 395 396
 * Prepares variables for book navigation templates.
 *
 * Default template: book-navigation.html.twig.
Dries's avatar
Dries committed
397
 *
398 399
 * @param array $variables
 *   An associative array containing the following key:
400
 *   - book_link: An associative array of book link properties.
401
 *     Properties used: bid, link_title, depth, pid, nid.
402
 */
403 404 405 406 407
function template_preprocess_book_navigation(&$variables) {
  $book_link = $variables['book_link'];

  // Provide extra variables for themers. Not needed by default.
  $variables['book_id'] = $book_link['bid'];
408
  $variables['book_title'] = String::checkPlain($book_link['link_title']);
409
  $variables['book_url'] = \Drupal::url('node.view', array('node' => $book_link['bid']));
410 411
  $variables['current_depth'] = $book_link['depth'];
  $variables['tree'] = '';
412

413 414 415
  /** @var \Drupal\book\BookOutline $book_outline */
  $book_outline = \Drupal::service('book.outline');

416
  if ($book_link['nid']) {
417
    $variables['tree'] = $book_outline->childrenLinks($book_link);
Dries's avatar
 
Dries committed
418

419 420
    $build = array();

421
    if ($prev = $book_outline->prevLink($book_link)) {
422
      $prev_href = \Drupal::url('node.view', array('node' => $prev['nid']));
423 424 425 426
      $build['#attached']['drupal_add_html_head_link'][][] = array(
        'rel' => 'prev',
        'href' => $prev_href,
      );
427
      $variables['prev_url'] = $prev_href;
428
      $variables['prev_title'] = String::checkPlain($prev['title']);
Dries's avatar
 
Dries committed
429
    }
430

431 432 433 434
    /** @var \Drupal\book\BookManagerInterface $book_manager */
    $book_manager = \Drupal::service('book.manager');
    if ($book_link['pid'] && $parent = $book_manager->loadBookLink($book_link['pid'])) {
      $parent_href = \Drupal::url('node.view', array('node' => $book_link['pid']));
435 436 437 438
      $build['#attached']['drupal_add_html_head_link'][][] = array(
        'rel' => 'up',
        'href' => $parent_href,
      );
439
      $variables['parent_url'] = $parent_href;
440
      $variables['parent_title'] = String::checkPlain($parent['title']);
Dries's avatar
 
Dries committed
441
    }
442

443
    if ($next = $book_outline->nextLink($book_link)) {
444
      $next_href = \Drupal::url('node.view', array('node' => $next['nid']));
445 446 447 448
      $build['#attached']['drupal_add_html_head_link'][][] = array(
        'rel' => 'next',
        'href' => $next_href,
      );
449
      $variables['next_url'] = $next_href;
450
      $variables['next_title'] = String::checkPlain($next['title']);
Dries's avatar
 
Dries committed
451
    }
452
  }
Dries's avatar
 
Dries committed
453

454 455 456 457
  if (!empty($build)) {
    drupal_render($build);
  }

458 459 460 461 462 463 464 465 466 467 468
  $variables['has_links'] = FALSE;
  // Link variables to filter for values and set state of the flag variable.
  $links = array('prev_url', 'prev_title', 'parent_url', 'parent_title', 'next_url', 'next_title');
  foreach ($links as $link) {
    if (isset($variables[$link])) {
      // Flag when there is a value.
      $variables['has_links'] = TRUE;
    }
    else {
      // Set empty to prevent notices.
      $variables[$link] = '';
469
    }
Dries's avatar
 
Dries committed
470
  }
Dries's avatar
 
Dries committed
471
}
Dries's avatar
 
Dries committed
472

473
/**
474
 * Prepares variables for book export templates.
475
 *
476
 * Default template: book-export-html.html.twig.
477
 *
478 479 480 481 482
 * @param array $variables
 *   An associative array containing:
 *   - title: The title of the book.
 *   - contents: Output of each book page.
 *   - depth: The max depth of the book.
483 484
 */
function template_preprocess_book_export_html(&$variables) {
485
  global $base_url;
486
  $language_interface = \Drupal::languageManager()->getCurrentLanguage();
487

488
  $variables['title'] = String::checkPlain($variables['title']);
489
  $variables['base_url'] = $base_url;
490
  $variables['language'] = $language_interface;
491
  $variables['language_rtl'] = ($language_interface->direction == Language::DIRECTION_RTL);
492
  $variables['head'] = drupal_get_html_head();
493 494

  // HTML element attributes.
495
  $attributes = array();
496
  $attributes['lang'] = $language_interface->id;
497 498
  $attributes['dir'] = $language_interface->direction ? 'rtl' : 'ltr';
  $variables['html_attributes'] = new Attribute($attributes);
499 500
}

501
/**
502 503 504
 * Prepares variables for single node export templates.
 *
 * Default template: book-node-export-html.html.twig.
Dries's avatar
Dries committed
505
 *
506 507
 * @param array $variables
 *   An associative array containing the following keys:
508 509 510
 *   - node: The node that will be output.
 *   - children: All the rendered child nodes within the current node. Defaults
 *     to an empty string.
511
 */
512 513
function template_preprocess_book_node_export_html(&$variables) {
  $variables['depth'] = $variables['node']->book['depth'];
514
  $variables['title'] = String::checkPlain($variables['node']->label());
515
  $variables['content'] = $variables['node']->rendered;
516 517
}

518 519 520 521 522 523 524
/**
 * Implements template_preprocess_HOOK() for theme_book_tree().
 */
function template_preprocess_book_tree(&$variables) {
  $variables['tree'] = $variables['tree']['#children'];
}

525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545
/**
 * Returns HTML for a book link and subtree.
 *
 * @param array $variables
 *   An associative array containing:
 *   - element: Structured array data for a book link.
 *
 * @ingroup themeable
 */
function theme_book_link(array $variables) {
  $element = $variables['element'];
  $sub_menu = '';

  if ($element['#below']) {
    $sub_menu = drupal_render($element['#below']);
  }
  $element['#localized_options']['set_active_class'] = TRUE;
  $output = l($element['#title'], $element['#href'], $element['#localized_options']);
  return '<li' . new Attribute($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}

546
/**
547
 * Determines if a given node type is in the list of types allowed for books.
548 549 550 551 552 553
 *
 * @param string $type
 *   A node type.
 *
 * @return bool
 *   A Boolean TRUE if the node type can be included in books; otherwise, FALSE.
554
 */
Dries's avatar
Dries committed
555
function book_type_is_allowed($type) {
556
  return in_array($type, \Drupal::config('book.settings')->get('allowed_types'));
557 558
}

Dries's avatar
Dries committed
559
/**
560
 * Implements hook_node_type_update().
Dries's avatar
Dries committed
561
 *
562 563
 * Updates book.settings configuration object if the machine-readable name of a
 * node type is changed.
Dries's avatar
Dries committed
564
 */
565
function book_node_type_update(NodeTypeInterface $type) {
566
  if ($type->getOriginalId() != $type->id()) {
567
    $config = \Drupal::config('book.settings');
568
    // Update the list of node types that are allowed to be added to books.
569
    $allowed_types = $config->get('allowed_types');
570
    $old_key = array_search($type->getOriginalId(), $allowed_types);
571

572
    if ($old_key !== FALSE) {
573
      $allowed_types[$old_key] = $type->id();
574
      // Ensure that the allowed_types array is sorted consistently.
575
      // @see BookSettingsForm::submitForm()
576
      sort($allowed_types);
577
      $config->set('allowed_types', $allowed_types);
578 579 580
    }

    // Update the setting for the "Add child page" link.
581
    if ($config->get('child_type') == $type->getOriginalId()) {
582
      $config->set('child_type', $type->id());
583
    }
584
    $config->save();
Dries's avatar
Dries committed
585
  }
Dries's avatar
 
Dries committed
586
}