TwigPluginBase.php in Twig Extender 8
File
src/Plugin/Twig/TwigPluginBase.php
View source
<?php
namespace Drupal\twig_extender\Plugin\Twig;
use Drupal\Core\Plugin\PluginBase;
class TwigPluginBase extends PluginBase implements TwigExtensionInterface {
public function getType() {
return $this->pluginDefinition['type'];
}
public function getName() {
return $this->pluginDefinition['name'];
}
public function getFunction() {
return $this->pluginDefinition['function'];
}
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(),
));
}
}