Skip to content

Drupal\helper\Twig\HelperExtension

Twig extension with some useful functions and filters.

Implements:

Twig\Extension\ExtensionInterface, Twig\Extension\LastModifiedExtensionInterface

Extend:

Twig\Extension\AbstractExtension

Methods

Name Description
__construct Constructs \Drupal\helper\Twig\HelperExtension.
fileDataUri Converts a file URL into a data URI.
getName {@inheritdoc}

Inherited methods

Name Description
getExpressionParsers -
getFilters -
getFunctions -
getLastModified -
getNodeVisitors -
getOperators -
getTests -
getTokenParsers -

HelperExtension::__construct

Description

public __construct (\Drupal\helper\File $file_helper, \Psr\Log\LoggerInterface $logger)

Constructs \Drupal\helper\Twig\HelperExtension.

Parameters

  • (\Drupal\helper\File) $file_helper :
    The file helper.
  • (\Psr\Log\LoggerInterface) $logger :
    The logger.

Return Values

void


HelperExtension::fileDataUri

Description

public fileDataUri (string $uri, bool $base_64_encode, string|null $mimetype)

Converts a file URL into a data URI.

Parameters

  • (string) $uri :
    The file URI.
  • (bool) $base_64_encode :
    TRUE to return the data URI as base-64 encoded content.
  • (string|null) $mimetype :
    The optional mime type to provide for the data URI. If not provided
    the mime type guesser service will be used.

Return Values

string

The image data URI for use in a src attribute.


HelperExtension::getName

Description

public getName (void)

{@inheritdoc}

Parameters

This function has no parameters.

Return Values

void