class Files in Bamboo Twig 8
Provides a 'Files' Twig Extensions.
Hierarchy
- class \Drupal\bamboo_twig_files\TwigExtension\Files extends \Drupal\bamboo_twig_files\TwigExtension\Twig_Extension
Expanded class hierarchy of Files
1 string reference to 'Files'
- bamboo_twig_files.services.yml in bamboo_twig_files/
bamboo_twig_files.services.yml - bamboo_twig_files/bamboo_twig_files.services.yml
1 service uses Files
File
- bamboo_twig_files/
src/ TwigExtension/ Files.php, line 10
Namespace
Drupal\bamboo_twig_files\TwigExtensionView source
class Files extends \Twig_Extension {
/**
* List of all Twig functions.
*/
public function getFunctions() {
return [
new \Twig_SimpleFunction('theme_url', [
$this,
'themeUrl',
], [
'is_safe' => [
'html',
],
]),
];
}
/**
* List of all Twig functions.
*/
public function getFilters() {
return [
new \Twig_SimpleFilter('extension_guesser', [
$this,
'extensionGuesser',
]),
];
}
/**
* Unique identifier for this Twig extension.
*/
public function getName() {
return 'bamboo_twig.twig.files';
}
/**
* Render a custom date format with Twig.
*
* Use the internal helper "format_date" to render the date
* using the current language for texts.
*/
public static function extensionGuesser($mime_type) {
$guesser = ExtensionGuesser::getInstance();
return $guesser
->guess($mime_type);
}
/**
* Generate an absolute url to the given theme.
*
* @param string $theme
* Theme name.
* @param string $file
* File path from theme root.
*
* @return string
* Absolute url to the given file in the theme.
*/
public static function themeUrl($theme, $file) {
return file_create_url(drupal_get_path('theme', $theme) . '/' . $file);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Files:: |
public static | function | Render a custom date format with Twig. | |
Files:: |
public | function | List of all Twig functions. | |
Files:: |
public | function | List of all Twig functions. | |
Files:: |
public | function | Unique identifier for this Twig extension. | |
Files:: |
public static | function | Generate an absolute url to the given theme. |