You are here

function theme_icon in Icon API 8

Same name and namespace in other branches
  1. 7 includes/theme.inc \theme_icon()

Theming responsibility is always passed to the bundle provider.

Parameters

array $variables: The variables array.

WARNING: This theming hook should never be overridden.

1 theme call to theme_icon()
icon_bundle_list in includes/admin.inc
Menu callback for 'icon_bundle_list'.

File

includes/theme.inc, line 123
theme.inc Provides hooks and functions for theme related tasks.

Code

function theme_icon($variables) {
  $output = '';
  $bundle = $variables['bundle'];
  $icon = $variables['icon'];
  if (!empty($bundle) && !empty($icon)) {

    // Render the icon.
    // @todo This should be a render array, but converting the variables to
    // render array properties is needed to do that and this is proxying them.
    // @FIXME
    // theme() has been renamed to _theme() and should NEVER be called directly.
    // Calling _theme() directly can alter the expected output and potentially
    // introduce security issues (see https://www.drupal.org/node/2195739). You
    // should use renderable arrays instead.
    //
    //
    // @see https://www.drupal.org/node/2195739
    // $output = theme('icon_' . $bundle['render'], $variables);
    // Wrap icon, if necessary.
    if (($wrapper = $variables['wrapper']) && in_array($wrapper, array_keys(icon_wrapper_options()))) {
      $build = array(
        '#theme' => 'html_tag__icon_wrapper',
        '#tag' => $wrapper,
        '#attributes' => $variables['wrapper_attributes'],
        '#value' => $output,
      );
      $output = \Drupal::service("renderer")
        ->render($build);
    }
  }
  return $output;
}