W3cubDocs

/Symfony 4.1

TwigExtension

class TwigExtension extends Extension

TwigExtension.

Methods

string getXsdValidationBasePath()

Returns the base path for the XSD files.

string getNamespace()

Returns the namespace to be used for this extension (XML namespace).

string getAlias()

Returns the recommended alias to use in XML.

from Extension
ConfigurationInterface|null getConfiguration(array $config, ContainerBuilder $container)

Returns extension configuration.

from Extension
processConfiguration(ConfigurationInterface $configuration, array $configs) from Extension
getProcessedConfigs() from Extension
bool isConfigEnabled(ContainerBuilder $container, array $config) from Extension
array getAnnotatedClassesToCompile()

Gets the annotated classes to cache.

from Extension
addAnnotatedClassesToCompile(array $annotatedClasses)

Adds annotated classes to the class cache.

from Extension
load(array $configs, ContainerBuilder $container)

Loads a specific configuration.

Details

string getXsdValidationBasePath()

Returns the base path for the XSD files.

Return Value

string The XSD base path

string getNamespace()

Returns the namespace to be used for this extension (XML namespace).

Return Value

string The XML namespace

string getAlias()

Returns the recommended alias to use in XML.

This alias is also the mandatory prefix to use when using YAML.

This convention is to remove the "Extension" postfix from the class name and then lowercase and underscore the result. So:

AcmeHelloExtension

becomes

acme_hello

This can be overridden in a sub-class to specify the alias manually.

Return Value

string The alias

Exceptions

BadMethodCallException When the extension name does not follow conventions

ConfigurationInterface|null getConfiguration(array $config, ContainerBuilder $container)

Returns extension configuration.

Parameters

array $config
ContainerBuilder $container

Return Value

ConfigurationInterface|null The configuration or null

final protected processConfiguration(ConfigurationInterface $configuration, array $configs)

Parameters

ConfigurationInterface $configuration
array $configs

final getProcessedConfigs()

protected bool isConfigEnabled(ContainerBuilder $container, array $config)

Parameters

ContainerBuilder $container
array $config

Return Value

bool Whether the configuration is enabled

Exceptions

InvalidArgumentException When the config is not enableable

array getAnnotatedClassesToCompile()

Gets the annotated classes to cache.

Return Value

array An array of classes

addAnnotatedClassesToCompile(array $annotatedClasses)

Adds annotated classes to the class cache.

Parameters

array $annotatedClasses An array of class patterns

load(array $configs, ContainerBuilder $container)

Loads a specific configuration.

Parameters

array $configs
ContainerBuilder $container

Exceptions

InvalidArgumentException When provided tag is not defined in this extension

© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.html