Issue #1898038 by jenlampton, joelpittet, duellj, Cottser, Shawn DeArmond, widukind, ezeedub, c4rl: Custom_block().module - Convert theme_ functions to Twig.
parent
7f99ae9e99
commit
cd4c61e425
|
@ -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 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.
|
||||
*
|
||||
|
|
|
@ -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 %}
|
Loading…
Reference in New Issue