block_content.pages.inc 933 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * @file
  4. * Provides page callbacks for custom blocks.
  5. */
  6. use Drupal\Core\Url;
  7. /**
  8. * Prepares variables for a custom block type creation list templates.
  9. *
  10. * Default template: block-content-add-list.html.twig.
  11. *
  12. * @param array $variables
  13. * An associative array containing:
  14. * - content: An array of block types.
  15. *
  16. * @see block_content_add_page()
  17. */
  18. function template_preprocess_block_content_add_list(&$variables) {
  19. $variables['types'] = [];
  20. $query = \Drupal::request()->query->all();
  21. foreach ($variables['content'] as $type) {
  22. $variables['types'][$type->id()] = [
  23. 'link' => \Drupal::l($type->label(), new Url('block_content.add_form', ['block_content_type' => $type->id()], ['query' => $query])),
  24. 'description' => [
  25. '#markup' => $type->getDescription(),
  26. ],
  27. 'title' => $type->label(),
  28. 'localized_options' => [
  29. 'query' => $query,
  30. ],
  31. ];
  32. }
  33. }