class File in Bamboo Twig 8.2
Same name and namespace in other branches
- 8.5 bamboo_twig_file/src/TwigExtension/File.php \Drupal\bamboo_twig_file\TwigExtension\File
- 8.3 bamboo_twig_file/src/TwigExtension/File.php \Drupal\bamboo_twig_file\TwigExtension\File
- 8.4 bamboo_twig_file/src/TwigExtension/File.php \Drupal\bamboo_twig_file\TwigExtension\File
Provides a 'File' Twig Extensions.
Hierarchy
- class \Drupal\bamboo_twig\TwigExtension\TwigExtensionBase extends \Drupal\bamboo_twig\TwigExtension\Twig_Extension uses \Symfony\Component\DependencyInjection\ContainerAwareTrait
- class \Drupal\bamboo_twig_file\TwigExtension\File
Expanded class hierarchy of File
1 string reference to 'File'
- bamboo_twig_file.services.yml in bamboo_twig_file/
bamboo_twig_file.services.yml - bamboo_twig_file/bamboo_twig_file.services.yml
1 service uses File
File
- bamboo_twig_file/
src/ TwigExtension/ File.php, line 10
Namespace
Drupal\bamboo_twig_file\TwigExtensionView source
class File extends TwigExtensionBase {
/**
* List of all Twig functions.
*/
public function getFilters() {
return [
new \Twig_SimpleFilter('bamboo_file_extension_guesser', [
$this,
'extensionGuesser',
]),
];
}
/**
* List of all Twig functions.
*/
public function getFunctions() {
return [
new \Twig_SimpleFunction('bamboo_file_url_absolute', [
$this,
'urlAbsolute',
]),
];
}
/**
* Unique identifier for this Twig extension.
*/
public function getName() {
return 'bamboo_twig_file.twig.file';
}
/**
* Render a custom date format with Twig.
*
* Use the internal helper "format_date" to render the date
* using the current language for texts.
*/
public function extensionGuesser($mime_type) {
return $this
->getExtensionGuesser()
->guess($mime_type);
}
/**
* Creates a web-accessible URL for a stream to an external or local file.
*
* @param string $uri
* The URI to a file for which we need an external URL,
* or the path to a shipped file.
*
* @return string
* A string containing a URL that may be used to access the file.
* If the provided string already contains a preceding 'http',
* 'https', or '/', nothing is done and the same string is returned.
* If a stream wrapper could not be found to generate an external URL,
* then FALSE is returned
*/
public function urlAbsolute($uri) {
return file_create_url($uri);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
File:: |
public | function | Render a custom date format with Twig. | |
File:: |
public | function | List of all Twig functions. | |
File:: |
public | function | List of all Twig functions. | |
File:: |
public | function |
Unique identifier for this Twig extension. Overrides TwigExtensionBase:: |
|
File:: |
public | function | Creates a web-accessible URL for a stream to an external or local file. | |
TwigExtensionBase:: |
protected | function | Return the block storage. | |
TwigExtensionBase:: |
protected | function | Provides an interface for a configuration object factory. | |
TwigExtensionBase:: |
protected | function | Return the current route match. | |
TwigExtensionBase:: |
protected | function | Lazy loading for the Drupal current user account proxy. | |
TwigExtensionBase:: |
protected | function | Provides a service to handle various date related functionality. | |
TwigExtensionBase:: |
protected | function | Lazy loading for the Drupal entity type manager. | |
TwigExtensionBase:: |
protected | function | Return a singleton mime type to file extension guesser. | |
TwigExtensionBase:: |
protected | function | Return the factory for image objects. | |
TwigExtensionBase:: |
protected | function | Return the file storage. | |
TwigExtensionBase:: |
protected | function | Provides helpers to operate on files and stream wrappers. | |
TwigExtensionBase:: |
protected | function | Provides an interface for form building and processing. | |
TwigExtensionBase:: |
protected | function | Return the factory for image objects. | |
TwigExtensionBase:: |
protected | function | Provides an interface defining an image style. | |
TwigExtensionBase:: |
protected | function | Returns the language manager service. | |
TwigExtensionBase:: |
protected | function | Interface for loading, transforming and rendering menu link trees. | |
TwigExtensionBase:: |
protected | function | Manages discovery and instantiation of block plugins. | |
TwigExtensionBase:: |
protected | function | Read only settings singleton. | |
TwigExtensionBase:: |
protected | function | The state storage service. | |
TwigExtensionBase:: |
protected | function | Return the token service. | |
TwigExtensionBase:: |
protected | function | Return the user storage. |