You are here

public function TwigPluginBase::register in Twig Extender 8

Same name and namespace in other branches
  1. 8.4 src/Plugin/Twig/TwigPluginBase.php \Drupal\twig_extender\Plugin\Twig\TwigPluginBase::register()
  2. 8.2 src/Plugin/Twig/TwigPluginBase.php \Drupal\twig_extender\Plugin\Twig\TwigPluginBase::register()
  3. 8.3 src/Plugin/Twig/TwigPluginBase.php \Drupal\twig_extender\Plugin\Twig\TwigPluginBase::register()
  4. 4.x src/Plugin/Twig/TwigPluginBase.php \Drupal\twig_extender\Plugin\Twig\TwigPluginBase::register()

Get type of the twig extension.

Overrides TwigExtensionInterface::register

File

src/Plugin/Twig/TwigPluginBase.php, line 36

Class

TwigPluginBase
Provides a base class for Twig plugins plugins.

Namespace

Drupal\twig_extender\Plugin\Twig

Code

public function register() {
  if ($this
    ->getType() == 'function') {
    return new \Twig_SimpleFunction($this
      ->getName(), array(
      $this,
      $this
        ->getFunction(),
    ));
  }
  return new \Twig_SimpleFilter($this
    ->getName(), array(
    $this,
    $this
      ->getFunction(),
  ));
}