summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2013-06-09 10:37:29 (GMT)
committerAlex Pott2013-06-09 10:37:29 (GMT)
commitcd4c61e425f2958ec74f16e5a04432308726126b (patch)
treecb4c964756af416cc03777162bda161d83140fad
parent7f99ae9e9932ff40695afd1693218130aa21b82e (diff)
Issue #1898038 by jenlampton, joelpittet, duellj, Cottser, Shawn DeArmond, widukind, ezeedub, c4rl: Custom_block().module - Convert theme_ functions to Twig.
-rw-r--r--core/modules/block/custom_block/custom_block.module16
-rw-r--r--core/modules/block/custom_block/custom_block.pages.inc27
-rw-r--r--core/modules/block/custom_block/templates/custom-block-add-list.html.twig25
3 files changed, 36 insertions, 32 deletions
diff --git a/core/modules/block/custom_block/custom_block.module b/core/modules/block/custom_block/custom_block.module
index b8785de..9273caf 100644
--- a/core/modules/block/custom_block/custom_block.module
+++ b/core/modules/block/custom_block/custom_block.module
@@ -115,29 +115,15 @@ function custom_block_menu() {
*/
function custom_block_theme($existing, $type, $theme, $path) {
return array(
- 'custom_block_block' => array(
- 'variables' => array('body' => NULL, 'format' => NULL),
- ),
'custom_block_add_list' => array(
'variables' => array('content' => NULL),
'file' => 'custom_block.pages.inc',
+ 'template' => 'custom-block-add-list',
),
);
}
/**
- * Returns HTML for a custom block.
- *
- * @ingroup themeable
- */
-function theme_custom_block_block($variables) {
- $body = $variables['body'];
- $format = $variables['format'];
-
- return check_markup($body, $format);
-}
-
-/**
* Loads a custom block type.
*
* @param int $id
diff --git a/core/modules/block/custom_block/custom_block.pages.inc b/core/modules/block/custom_block/custom_block.pages.inc
index 9c802c4..297475c 100644
--- a/core/modules/block/custom_block/custom_block.pages.inc
+++ b/core/modules/block/custom_block/custom_block.pages.inc
@@ -10,32 +10,25 @@ use Drupal\custom_block\Plugin\Core\Entity\CustomBlock;
use Symfony\Component\HttpFoundation\RedirectResponse;
/**
- * Returns HTML for a list of available custom block types for block creation.
+ * Prepares variables for a custom block type creation list templates.
*
- * @param $variables
+ * Default template: custom-block-add-list.html.twig.
+ *
+ * @param array $variables
* An associative array containing:
* - content: An array of block types.
*
* @see custom_block_add_page()
- *
- * @ingroup themeable
*/
-function theme_custom_block_add_list($variables) {
- $content = $variables['content'];
- $output = '';
-
- if ($content) {
- $output = '<dl class="node-type-list">';
- foreach ($content as $type) {
- $output .= '<dt>' . l($type->label(), 'block/add/' . $type->id()) . '</dt>';
- $output .= '<dd>' . filter_xss_admin($type->description) . '</dd>';
- }
- $output .= '</dl>';
+function template_preprocess_custom_block_add_list(&$variables) {
+ $variables['types'] = array();
+ foreach ($variables['content'] as $type) {
+ $variables['types'][$type->id] = array();
+ $variables['types'][$type->id]['link'] = l($type->label(), 'block/add/' . $type->id());
+ $variables['types'][$type->id]['description'] = filter_xss_admin($type->description);
}
- return $output;
}
-
/**
* Page callback: Presents the custom block creation form.
*
diff --git a/core/modules/block/custom_block/templates/custom-block-add-list.html.twig b/core/modules/block/custom_block/templates/custom-block-add-list.html.twig
new file mode 100644
index 0000000..2878da2
--- /dev/null
+++ b/core/modules/block/custom_block/templates/custom-block-add-list.html.twig
@@ -0,0 +1,25 @@
+{#
+/**
+ * @file
+ * Default theme implementation to present a list of custom block types.
+ *
+ * Available variables:
+ * - types: A collection of all the available custom block types.
+ * Each block type contains the following:
+ * - link: A link to add a block of this type.
+ * - description: A description of this custom block type.
+ *
+ * @see template_preprocess()
+ * @see template_preprocess_custom_block_add_list()
+ *
+ * @ingroup themeable
+ */
+#}
+{% spaceless %}
+ <dl class="node-type-list">
+ {% for type in types %}
+ <dt>{{ type.link }}</dt>
+ <dd>{{ type.description }}</dd>
+ {% endfor %}
+ </dl>
+{% endspaceless %}