You are here

class Path in Bamboo Twig 8.3

Same name and namespace in other branches
  1. 8.5 bamboo_twig_path/src/TwigExtension/Path.php \Drupal\bamboo_twig_path\TwigExtension\Path
  2. 8.2 bamboo_twig_path/src/TwigExtension/Path.php \Drupal\bamboo_twig_path\TwigExtension\Path
  3. 8.4 bamboo_twig_path/src/TwigExtension/Path.php \Drupal\bamboo_twig_path\TwigExtension\Path

Provides a 'Path' Twig Extensions.

Hierarchy

  • class \Drupal\bamboo_twig_path\TwigExtension\Path extends \Drupal\bamboo_twig_path\TwigExtension\Twig_Extension

Expanded class hierarchy of Path

1 string reference to 'Path'
bamboo_twig_path.services.yml in bamboo_twig_path/bamboo_twig_path.services.yml
bamboo_twig_path/bamboo_twig_path.services.yml
1 service uses Path
bamboo_twig_path.twig.path in bamboo_twig_path/bamboo_twig_path.services.yml
Drupal\bamboo_twig_path\TwigExtension\Path

File

bamboo_twig_path/src/TwigExtension/Path.php, line 8

Namespace

Drupal\bamboo_twig_path\TwigExtension
View source
class Path extends \Twig_Extension {

  /**
   * List of all Twig functions.
   */
  public function getFunctions() {
    return [
      new \Twig_SimpleFunction('bamboo_path_system', [
        $this,
        'getSystemPath',
      ]),
    ];
  }

  /**
   * Unique identifier for this Twig extension.
   */
  public function getName() {
    return 'bamboo_twig_path.twig.path';
  }

  /**
   * Returns the path to a system item (module, theme, etc.).
   *
   * @param string $type
   *   The type of the item; one of 'core', 'profile', 'module', 'theme',
   *   or 'theme_engine'.
   * @param string $name
   *   The name of the item for which the path is requested.
   *   Ignored for $type 'core'.
   *
   * @return string
   *   The path to the requested item or an empty string
   *   if the item is not found.
   */
  public function getSystemPath($type, $name = NULL) {
    return drupal_get_path($type, $name);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Path::getFunctions public function List of all Twig functions.
Path::getName public function Unique identifier for this Twig extension.
Path::getSystemPath public function Returns the path to a system item (module, theme, etc.).