2013-02-18 22:17:49 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* Provides page callbacks for custom blocks.
|
|
|
|
*/
|
|
|
|
|
2014-09-29 13:41:29 +00:00
|
|
|
use Drupal\Core\Url;
|
2013-02-18 22:17:49 +00:00
|
|
|
|
|
|
|
/**
|
2013-06-09 10:37:29 +00:00
|
|
|
* Prepares variables for a custom block type creation list templates.
|
2013-02-18 22:17:49 +00:00
|
|
|
*
|
2014-06-09 20:19:08 +00:00
|
|
|
* Default template: block-content-add-list.html.twig.
|
2013-06-09 10:37:29 +00:00
|
|
|
*
|
|
|
|
* @param array $variables
|
2013-02-18 22:17:49 +00:00
|
|
|
* An associative array containing:
|
|
|
|
* - content: An array of block types.
|
|
|
|
*
|
2014-06-09 20:19:08 +00:00
|
|
|
* @see block_content_add_page()
|
2013-02-18 22:17:49 +00:00
|
|
|
*/
|
2014-06-09 20:19:08 +00:00
|
|
|
function template_preprocess_block_content_add_list(&$variables) {
|
2017-03-04 01:20:24 +00:00
|
|
|
$variables['types'] = [];
|
2013-09-16 03:58:06 +00:00
|
|
|
$query = \Drupal::request()->query->all();
|
2013-06-09 10:37:29 +00:00
|
|
|
foreach ($variables['content'] as $type) {
|
2017-03-04 01:20:24 +00:00
|
|
|
$variables['types'][$type->id()] = [
|
|
|
|
'link' => \Drupal::l($type->label(), new Url('block_content.add_form', ['block_content_type' => $type->id()], ['query' => $query])),
|
|
|
|
'description' => [
|
2015-07-11 08:10:48 +00:00
|
|
|
'#markup' => $type->getDescription(),
|
2017-03-04 01:20:24 +00:00
|
|
|
],
|
2013-09-12 00:35:09 +00:00
|
|
|
'title' => $type->label(),
|
2017-03-04 01:20:24 +00:00
|
|
|
'localized_options' => [
|
2013-09-12 00:35:09 +00:00
|
|
|
'query' => $query,
|
2017-03-04 01:20:24 +00:00
|
|
|
],
|
|
|
|
];
|
2013-02-18 22:17:49 +00:00
|
|
|
}
|
|
|
|
}
|