Commit cd4c61e4 authored by alexpott's avatar alexpott

Issue #1898038 by jenlampton, joelpittet, duellj, Cottser, Shawn DeArmond,...

Issue #1898038 by jenlampton, joelpittet, duellj, Cottser, Shawn DeArmond, widukind, ezeedub, c4rl: Custom_block().module - Convert theme_ functions to Twig.
parent 7f99ae9e
......@@ -115,28 +115,14 @@ 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.
*
......
......@@ -10,32 +10,25 @@
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>';
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);
}
$output .= '</dl>';
}
return $output;
}
/**
* Page callback: Presents the custom block creation form.
*
......
{#
/**
* @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 %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment