You are here

class Micon in Micon 8

Same name in this branch
  1. 8 src/TwigExtension/Micon.php \Drupal\micon\TwigExtension\Micon
  2. 8 src/Element/Micon.php \Drupal\micon\Element\Micon
  3. 8 src/Entity/Micon.php \Drupal\micon\Entity\Micon
  4. 8 src/Plugin/SocialMediaLinks/Iconset/Micon.php \Drupal\micon\Plugin\SocialMediaLinks\Iconset\Micon
Same name and namespace in other branches
  1. 2.x src/TwigExtension/Micon.php \Drupal\micon\TwigExtension\Micon

A class providing Micon Twig extensions.

This provides a Twig extension that registers the {{ micon() }} extension to Twig.

Hierarchy

  • class \Drupal\micon\TwigExtension\Micon extends \Drupal\micon\TwigExtension\Twig_Extension

Expanded class hierarchy of Micon

9 string references to 'Micon'
micon.info.yml in ./micon.info.yml
micon.info.yml
micon.links.menu.yml in ./micon.links.menu.yml
micon.links.menu.yml
micon.services.yml in ./micon.services.yml
micon.services.yml
micon_content_type.info.yml in micon_content_type/micon_content_type.info.yml
micon_content_type/micon_content_type.info.yml
micon_link.info.yml in micon_link/micon_link.info.yml
micon_link/micon_link.info.yml

... See full list

1 service uses Micon
twig.micon in ./micon.services.yml
Drupal\micon\TwigExtension\Micon

File

src/TwigExtension/Micon.php, line 11

Namespace

Drupal\micon\TwigExtension
View source
class Micon extends \Twig_Extension {

  /**
   * Gets a unique identifier for this Twig extension.
   *
   * @return string
   *   A unique identifier for this Twig extension.
   */
  public function getName() {
    return 'twig.micon';
  }

  /**
   * {@inheritdoc}
   */
  public function getFunctions() {
    return array(
      new \Twig_SimpleFunction('micon', array(
        $this,
        'renderIcon',
      )),
    );
  }

  /**
   * Render the icon.
   *
   * @param string $icon
   *   The icon_id of the icon to render.
   *
   * @return mixed[]
   *   A render array.
   */
  public static function renderIcon($icon) {
    $build = [
      '#theme' => 'micon_icon',
      '#icon' => $icon,
    ];
    return $build;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Micon::getFunctions public function
Micon::getName public function Gets a unique identifier for this Twig extension.
Micon::renderIcon public static function Render the icon.