You are here

protected static function ExtensionLoader::load in Unified Twig Extensions 1.0.x

Loads a specific plugin instance.

Parameters

string $type: The type of the plugin to be loaded.

string $file: The fully qualified path of the plugin to be loaded.

1 call to ExtensionLoader::load()
ExtensionLoader::loadAll in src/TwigExtension/ExtensionLoader.php
Loads all plugins of a given type.

File

src/TwigExtension/ExtensionLoader.php, line 78

Class

ExtensionLoader
Loads twig customizations from a dist directory.

Namespace

Drupal\unified_twig_ext\TwigExtension

Code

protected static function load($type, $file) {
  include $file;
  switch ($type) {
    case 'filters':
      if (isset($filter)) {
        self::$objects['filters'][] = $filter;
      }
      break;
    case 'functions':
      if (isset($function)) {
        self::$objects['functions'][] = $function;
      }
      break;
    case 'tags':
      if (preg_match('/^([^\\.]+)\\.tag\\.php$/', basename($file), $matches)) {
        $class = "Project_{$matches[1]}_TokenParser";
        if (class_exists($class)) {
          self::$objects['parsers'][] = new $class();
        }
      }
      break;
  }
}