uc_attribute.theme.inc in Ubercart 8.4
Same filename and directory in other branches
Attribute theme functions.
File
uc_attribute/uc_attribute.theme.incView source
<?php
/**
* @file
* Attribute theme functions.
*/
use Drupal\Core\Render\Element;
/**
* Returns a themed set of attribute options for use in order displays.
*
* @param array $variables
* An associative array containing:
* - attributes: An associative array containing the set of attributes,
* with each element keyed by attribute ID:
* - <aid>: An associative array containing:
* - #attribute_name: Attribute name.
* - #options: Array of option names.
*
* @return string
* Themed set of attribute options.
*
* @ingroup themeable
*/
function theme_uc_product_attributes(array $variables) {
$attributes = $variables['attributes'];
$option_rows = [];
foreach (Element::children($attributes) as $key) {
$optionstr = '';
foreach ((array) $attributes[$key]['#options'] as $option) {
// We only need to allow translation from the second option onward.
if (empty($optionstr)) {
$optionstr .= $option;
}
else {
$optionstr .= t(', @option', [
'@option' => $option,
]);
}
}
if ($optionstr != '') {
$option_rows[$key] = t('@attribute: @option', [
'@attribute' => $attributes[$key]['#attribute_name'],
'@option' => $optionstr,
]);
}
}
if (!empty($option_rows)) {
$item_list = [
'#theme' => 'item_list',
'#items' => array_values($option_rows),
'#attributes' => [
'class' => [
'product-description',
],
],
];
return \Drupal::service('renderer')
->render($item_list);
}
return '';
}
Functions
Name![]() |
Description |
---|---|
theme_uc_product_attributes | Returns a themed set of attribute options for use in order displays. |