PEEL Shopping
Open source ecommerce : PEEL Shopping
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
Twig_Environment Class Reference

Stores the Twig configuration. More...

Public Member Functions

 __construct (Twig_LoaderInterface $loader=null, $options=array())
 Constructor. More...
 
 getBaseTemplateClass ()
 Gets the base template class for compiled templates. More...
 
 setBaseTemplateClass ($class)
 Sets the base template class for compiled templates. More...
 
 enableDebug ()
 Enables debugging mode. More...
 
 disableDebug ()
 Disables debugging mode. More...
 
 isDebug ()
 Checks if debug mode is enabled. More...
 
 enableAutoReload ()
 Enables the auto_reload option. More...
 
 disableAutoReload ()
 Disables the auto_reload option. More...
 
 isAutoReload ()
 Checks if the auto_reload option is enabled. More...
 
 enableStrictVariables ()
 Enables the strict_variables option. More...
 
 disableStrictVariables ()
 Disables the strict_variables option. More...
 
 isStrictVariables ()
 Checks if the strict_variables option is enabled. More...
 
 getCache ()
 Gets the cache directory or false if cache is disabled. More...
 
 setCache ($cache)
 Sets the cache directory or false if cache is disabled. More...
 
 getCacheFilename ($name)
 Gets the cache filename for a given template. More...
 
 getTemplateClass ($name, $index=null)
 Gets the template class associated with the given string. More...
 
 getTemplateClassPrefix ()
 Gets the template class prefix. More...
 
 render ($name, array $context=array())
 Renders a template. More...
 
 display ($name, array $context=array())
 Displays a template. More...
 
 loadTemplate ($name, $index=null)
 Loads a template by name. More...
 
 isTemplateFresh ($name, $time)
 Returns true if the template is still fresh. More...
 
 resolveTemplate ($names)
 
 clearTemplateCache ()
 Clears the internal template cache. More...
 
 clearCacheFiles ()
 Clears the template cache files on the filesystem. More...
 
 getLexer ()
 Gets the Lexer instance. More...
 
 setLexer (Twig_LexerInterface $lexer)
 Sets the Lexer instance. More...
 
 tokenize ($source, $name=null)
 Tokenizes a source code. More...
 
 getParser ()
 Gets the Parser instance. More...
 
 setParser (Twig_ParserInterface $parser)
 Sets the Parser instance. More...
 
 parse (Twig_TokenStream $tokens)
 Parses a token stream. More...
 
 getCompiler ()
 Gets the Compiler instance. More...
 
 setCompiler (Twig_CompilerInterface $compiler)
 Sets the Compiler instance. More...
 
 compile (Twig_NodeInterface $node)
 Compiles a Node. More...
 
 compileSource ($source, $name=null)
 Compiles a template source code. More...
 
 setLoader (Twig_LoaderInterface $loader)
 Sets the Loader instance. More...
 
 getLoader ()
 Gets the Loader instance. More...
 
 setCharset ($charset)
 Sets the default template charset. More...
 
 getCharset ()
 Gets the default template charset. More...
 
 initRuntime ()
 Initializes the runtime environment. More...
 
 hasExtension ($name)
 Returns true if the given extension is registered. More...
 
 getExtension ($name)
 Gets an extension by name. More...
 
 addExtension (Twig_ExtensionInterface $extension)
 Registers an extension. More...
 
 removeExtension ($name)
 Removes an extension by name. More...
 
 setExtensions (array $extensions)
 Registers an array of extensions. More...
 
 getExtensions ()
 Returns all registered extensions. More...
 
 addTokenParser (Twig_TokenParserInterface $parser)
 Registers a Token Parser. More...
 
 getTokenParsers ()
 Gets the registered Token Parsers. More...
 
 getTags ()
 Gets registered tags. More...
 
 addNodeVisitor (Twig_NodeVisitorInterface $visitor)
 Registers a Node Visitor. More...
 
 getNodeVisitors ()
 Gets the registered Node Visitors. More...
 
 addFilter ($name, $filter=null)
 Registers a Filter. More...
 
 getFilter ($name)
 Get a filter by name. More...
 
 registerUndefinedFilterCallback ($callable)
 
 getFilters ()
 Gets the registered Filters. More...
 
 addTest ($name, $test=null)
 Registers a Test. More...
 
 getTests ()
 Gets the registered Tests. More...
 
 getTest ($name)
 Gets a test by name. More...
 
 addFunction ($name, $function=null)
 Registers a Function. More...
 
 getFunction ($name)
 Get a function by name. More...
 
 registerUndefinedFunctionCallback ($callable)
 
 getFunctions ()
 Gets registered functions. More...
 
 addGlobal ($name, $value)
 Registers a Global. More...
 
 getGlobals ()
 Gets the registered Globals. More...
 
 mergeGlobals (array $context)
 Merges a context with the defined globals. More...
 
 getUnaryOperators ()
 Gets the registered unary Operators. More...
 
 getBinaryOperators ()
 Gets the registered binary Operators. More...
 
 computeAlternatives ($name, $items)
 

Data Fields

const VERSION = '1.13.2'
 

Protected Member Functions

 initGlobals ()
 
 initExtensions ()
 
 initExtension (Twig_ExtensionInterface $extension)
 
 writeCacheFile ($file, $content)
 

Protected Attributes

 $charset
 
 $loader
 
 $debug
 
 $autoReload
 
 $cache
 
 $lexer
 
 $parser
 
 $compiler
 
 $baseTemplateClass
 
 $extensions
 
 $parsers
 
 $visitors
 
 $filters
 
 $tests
 
 $functions
 
 $globals
 
 $runtimeInitialized
 
 $extensionInitialized
 
 $loadedTemplates
 
 $strictVariables
 
 $unaryOperators
 
 $binaryOperators
 
 $templateClassPrefix = '__TwigTemplate_'
 
 $functionCallbacks
 
 $filterCallbacks
 
 $staging
 

Detailed Description

Stores the Twig configuration.

Author
Fabien Potencier fabie.nosp@m.n@sy.nosp@m.mfony.nosp@m..com

Definition at line 17 of file Environment.php.

Constructor & Destructor Documentation

__construct ( Twig_LoaderInterface  $loader = null,
  $options = array() 
)

Constructor.

Available options:

  • debug: When set to true, it automatically set "auto_reload" to true as well (default to false).
  • charset: The charset used by the templates (default to UTF-8).
  • base_template_class: The base template class to use for generated templates (default to Twig_Template).
  • cache: An absolute path where to store the compiled templates, or false to disable compilation cache (default).
  • auto_reload: Whether to reload the template is the original source changed. If you don't provide the auto_reload option, it will be determined automatically base on the debug value.
  • strict_variables: Whether to ignore invalid variables in templates (default to false).
  • autoescape: Whether to enable auto-escaping (default to html):
    • false: disable auto-escaping
    • true: equivalent to html
    • html, js: set the autoescaping to one of the supported strategies
    • PHP callback: a PHP callback that returns an escaping strategy based on the template "filename"
  • optimizations: A flag that indicates which optimizations to apply (default to -1 which means that all optimizations are enabled; set it to 0 to disable).
Parameters
Twig_LoaderInterface$loaderA Twig_LoaderInterface instance
array$optionsAn array of options

Definition at line 84 of file Environment.php.

Member Function Documentation

addExtension ( Twig_ExtensionInterface  $extension)

Registers an extension.

Parameters
Twig_ExtensionInterface$extensionA Twig_ExtensionInterface instance

Definition at line 627 of file Environment.php.

addFilter (   $name,
  $filter = null 
)

Registers a Filter.

Parameters
string | Twig_SimpleFilter$nameThe filter name or a Twig_SimpleFilter instance
Twig_FilterInterface | Twig_SimpleFilter$filterA Twig_FilterInterface instance or a Twig_SimpleFilter instance

Definition at line 757 of file Environment.php.

addFunction (   $name,
  $function = null 
)

Registers a Function.

Parameters
string | Twig_SimpleFunction$nameThe function name or a Twig_SimpleFunction instance
Twig_FunctionInterface | Twig_SimpleFunction$functionA Twig_FunctionInterface instance or a Twig_SimpleFunction instance

Definition at line 904 of file Environment.php.

addGlobal (   $name,
  $value 
)

Registers a Global.

New globals can be added before compiling or rendering a template; but after, you can only update existing globals.

Parameters
string$nameThe global name
mixed$valueThe global value

Definition at line 996 of file Environment.php.

addNodeVisitor ( Twig_NodeVisitorInterface  $visitor)

Registers a Node Visitor.

Parameters
Twig_NodeVisitorInterface$visitorA Twig_NodeVisitorInterface instance

Definition at line 728 of file Environment.php.

addTest (   $name,
  $test = null 
)

Registers a Test.

Parameters
string | Twig_SimpleTest$nameThe test name or a Twig_SimpleTest instance
Twig_TestInterface | Twig_SimpleTest$testA Twig_TestInterface instance or a Twig_SimpleTest instance

Definition at line 846 of file Environment.php.

addTokenParser ( Twig_TokenParserInterface  $parser)

Registers a Token Parser.

Parameters
Twig_TokenParserInterface$parserA Twig_TokenParserInterface instance

Definition at line 681 of file Environment.php.

clearCacheFiles ( )

Clears the template cache files on the filesystem.

Definition at line 396 of file Environment.php.

clearTemplateCache ( )

Clears the internal template cache.

Definition at line 388 of file Environment.php.

compile ( Twig_NodeInterface  $node)

Compiles a Node.

Parameters
Twig_NodeInterface$nodeA Twig_NodeInterface instance
Returns
string The compiled PHP source code

Definition at line 513 of file Environment.php.

compileSource (   $source,
  $name = null 
)

Compiles a template source code.

Parameters
string$sourceThe template source code
string$nameThe template name
Returns
string The compiled PHP source code

Definition at line 526 of file Environment.php.

computeAlternatives (   $name,
  $items 
)

Definition at line 1084 of file Environment.php.

disableAutoReload ( )

Disables the auto_reload option.

Definition at line 175 of file Environment.php.

disableDebug ( )

Disables debugging mode.

Definition at line 149 of file Environment.php.

disableStrictVariables ( )

Disables the strict_variables option.

Definition at line 201 of file Environment.php.

display (   $name,
array  $context = array() 
)

Displays a template.

Parameters
string$nameThe template name
array$contextAn array of parameters to pass to the template

Definition at line 297 of file Environment.php.

enableAutoReload ( )

Enables the auto_reload option.

Definition at line 167 of file Environment.php.

enableDebug ( )

Enables debugging mode.

Definition at line 141 of file Environment.php.

enableStrictVariables ( )

Enables the strict_variables option.

Definition at line 193 of file Environment.php.

getBaseTemplateClass ( )

Gets the base template class for compiled templates.

Returns
string The base template class name

Definition at line 123 of file Environment.php.

getBinaryOperators ( )

Gets the registered binary Operators.

Returns
array An array of binary operators

Definition at line 1075 of file Environment.php.

getCache ( )

Gets the cache directory or false if cache is disabled.

Returns
string|false

Definition at line 221 of file Environment.php.

getCacheFilename (   $name)

Gets the cache filename for a given template.

Parameters
string$nameThe template name
Returns
string The cache file name

Definition at line 244 of file Environment.php.

getCharset ( )

Gets the default template charset.

Returns
string The default charset

Definition at line 577 of file Environment.php.

getCompiler ( )

Gets the Compiler instance.

Returns
Twig_CompilerInterface A Twig_CompilerInterface instance

Definition at line 487 of file Environment.php.

getExtension (   $name)

Gets an extension by name.

Parameters
string$nameThe extension name
Returns
Twig_ExtensionInterface A Twig_ExtensionInterface instance

Definition at line 613 of file Environment.php.

getExtensions ( )

Returns all registered extensions.

Returns
array An array of extensions

Definition at line 671 of file Environment.php.

getFilter (   $name)

Get a filter by name.

Subclasses may override this method and load filters differently; so no list of filters is available.

Parameters
string$nameThe filter name
Returns
Twig_Filter|false A Twig_Filter instance or false if the filter does not exist

Definition at line 785 of file Environment.php.

getFilters ( )

Gets the registered Filters.

Be warned that this method cannot return filters defined with registerUndefinedFunctionCallback.

Returns
Twig_FilterInterface[] An array of Twig_FilterInterface instances
See also
registerUndefinedFilterCallback

Definition at line 831 of file Environment.php.

getFunction (   $name)

Get a function by name.

Subclasses may override this method and load functions differently; so no list of functions is available.

Parameters
string$namefunction name
Returns
Twig_Function|false A Twig_Function instance or false if the function does not exist

Definition at line 932 of file Environment.php.

getFunctions ( )

Gets registered functions.

Be warned that this method cannot return functions defined with registerUndefinedFunctionCallback.

Returns
Twig_FunctionInterface[] An array of Twig_FunctionInterface instances
See also
registerUndefinedFunctionCallback

Definition at line 978 of file Environment.php.

getGlobals ( )

Gets the registered Globals.

Returns
array An array of globals

Definition at line 1023 of file Environment.php.

getLexer ( )

Gets the Lexer instance.

Returns
Twig_LexerInterface A Twig_LexerInterface instance

Definition at line 414 of file Environment.php.

getLoader ( )

Gets the Loader instance.

Returns
Twig_LoaderInterface A Twig_LoaderInterface instance

Definition at line 553 of file Environment.php.

getNodeVisitors ( )

Gets the registered Node Visitors.

Returns
Twig_NodeVisitorInterface[] An array of Twig_NodeVisitorInterface instances

Definition at line 742 of file Environment.php.

getParser ( )

Gets the Parser instance.

Returns
Twig_ParserInterface A Twig_ParserInterface instance

Definition at line 451 of file Environment.php.

getTags ( )

Gets registered tags.

Be warned that this method cannot return tags defined by Twig_TokenParserBrokerInterface classes.

Returns
Twig_TokenParserInterface[] An array of Twig_TokenParserInterface instances

Definition at line 711 of file Environment.php.

getTemplateClass (   $name,
  $index = null 
)

Gets the template class associated with the given string.

Parameters
string$nameThe name for which to calculate the template class name
integer$indexThe index if it is an embedded template
Returns
string The template class name

Definition at line 263 of file Environment.php.

getTemplateClassPrefix ( )

Gets the template class prefix.

Returns
string The template class prefix

Definition at line 273 of file Environment.php.

getTest (   $name)

Gets a test by name.

Parameters
string$nameThe test name
Returns
Twig_Test|false A Twig_Test instance or false if the test does not exist

Definition at line 885 of file Environment.php.

getTests ( )

Gets the registered Tests.

Returns
Twig_TestInterface[] An array of Twig_TestInterface instances

Definition at line 869 of file Environment.php.

getTokenParsers ( )

Gets the registered Token Parsers.

Returns
Twig_TokenParserBrokerInterface A broker containing token parsers

Definition at line 695 of file Environment.php.

getUnaryOperators ( )

Gets the registered unary Operators.

Returns
array An array of unary operators

Definition at line 1061 of file Environment.php.

hasExtension (   $name)

Returns true if the given extension is registered.

Parameters
string$nameThe extension name
Returns
Boolean Whether the extension is registered or not

Definition at line 601 of file Environment.php.

initExtension ( Twig_ExtensionInterface  $extension)
protected

Definition at line 1136 of file Environment.php.

initExtensions ( )
protected

Definition at line 1115 of file Environment.php.

initGlobals ( )
protected

Definition at line 1098 of file Environment.php.

initRuntime ( )

Initializes the runtime environment.

Definition at line 585 of file Environment.php.

isAutoReload ( )

Checks if the auto_reload option is enabled.

Returns
Boolean true if auto_reload is enabled, false otherwise

Definition at line 185 of file Environment.php.

isDebug ( )

Checks if debug mode is enabled.

Returns
Boolean true if debug mode is enabled, false otherwise

Definition at line 159 of file Environment.php.

isStrictVariables ( )

Checks if the strict_variables option is enabled.

Returns
Boolean true if strict_variables is enabled, false otherwise

Definition at line 211 of file Environment.php.

isTemplateFresh (   $name,
  $time 
)

Returns true if the template is still fresh.

Besides checking the loader for freshness information, this method also checks if the enabled extensions have not changed.

Parameters
string$nameThe template name
timestamp$timeThe last modification time of the cached template
Returns
Boolean true if the template is fresh, false otherwise

Definition at line 349 of file Environment.php.

loadTemplate (   $name,
  $index = null 
)

Loads a template by name.

Parameters
string$nameThe template name
integer$indexThe index if it is an embedded template
Returns
Twig_TemplateInterface A template instance representing the given template name

Definition at line 310 of file Environment.php.

mergeGlobals ( array  $context)

Merges a context with the defined globals.

Parameters
array$contextAn array representing the context
Returns
array The context merged with the globals

Definition at line 1043 of file Environment.php.

parse ( Twig_TokenStream  $tokens)

Parses a token stream.

Parameters
Twig_TokenStream$tokensA Twig_TokenStream instance
Returns
Twig_Node_Module A Node tree

Definition at line 477 of file Environment.php.

registerUndefinedFilterCallback (   $callable)

Definition at line 817 of file Environment.php.

registerUndefinedFunctionCallback (   $callable)

Definition at line 964 of file Environment.php.

removeExtension (   $name)

Removes an extension by name.

This method is deprecated and you should not use it.

Parameters
string$nameThe extension name

Definition at line 645 of file Environment.php.

render (   $name,
array  $context = array() 
)

Renders a template.

Parameters
string$nameThe template name
array$contextAn array of parameters to pass to the template
Returns
string The rendered template

Definition at line 286 of file Environment.php.

resolveTemplate (   $names)

Definition at line 361 of file Environment.php.

setBaseTemplateClass (   $class)

Sets the base template class for compiled templates.

Parameters
string$classThe base template class name

Definition at line 133 of file Environment.php.

setCache (   $cache)

Sets the cache directory or false if cache is disabled.

Parameters
string | false$cacheThe absolute path to the compiled templates, or false to disable cache

Definition at line 232 of file Environment.php.

setCharset (   $charset)

Sets the default template charset.

Parameters
string$charsetThe default charset

Definition at line 567 of file Environment.php.

setCompiler ( Twig_CompilerInterface  $compiler)

Sets the Compiler instance.

Parameters
Twig_CompilerInterface$compilerA Twig_CompilerInterface instance

Definition at line 501 of file Environment.php.

setExtensions ( array  $extensions)

Registers an array of extensions.

Parameters
array$extensionsAn array of extensions

Definition at line 659 of file Environment.php.

setLexer ( Twig_LexerInterface  $lexer)

Sets the Lexer instance.

Parameters
Twig_LexerInterfaceA Twig_LexerInterface instance

Definition at line 428 of file Environment.php.

setLoader ( Twig_LoaderInterface  $loader)

Sets the Loader instance.

Parameters
Twig_LoaderInterface$loaderA Twig_LoaderInterface instance

Definition at line 543 of file Environment.php.

setParser ( Twig_ParserInterface  $parser)

Sets the Parser instance.

Parameters
Twig_ParserInterfaceA Twig_ParserInterface instance

Definition at line 465 of file Environment.php.

tokenize (   $source,
  $name = null 
)

Tokenizes a source code.

Parameters
string$sourceThe template source code
string$nameThe template name
Returns
Twig_TokenStream A Twig_TokenStream instance

Definition at line 441 of file Environment.php.

writeCacheFile (   $file,
  $content 
)
protected

Definition at line 1201 of file Environment.php.

Field Documentation

$autoReload
protected

Definition at line 24 of file Environment.php.

$baseTemplateClass
protected

Definition at line 29 of file Environment.php.

$binaryOperators
protected

Definition at line 42 of file Environment.php.

$cache
protected

Definition at line 25 of file Environment.php.

$charset
protected

Definition at line 21 of file Environment.php.

$compiler
protected

Definition at line 28 of file Environment.php.

$debug
protected

Definition at line 23 of file Environment.php.

$extensionInitialized
protected

Definition at line 38 of file Environment.php.

$extensions
protected

Definition at line 30 of file Environment.php.

$filterCallbacks
protected

Definition at line 45 of file Environment.php.

$filters
protected

Definition at line 33 of file Environment.php.

$functionCallbacks
protected

Definition at line 44 of file Environment.php.

$functions
protected

Definition at line 35 of file Environment.php.

$globals
protected

Definition at line 36 of file Environment.php.

$lexer
protected

Definition at line 26 of file Environment.php.

$loadedTemplates
protected

Definition at line 39 of file Environment.php.

$loader
protected

Definition at line 22 of file Environment.php.

$parser
protected

Definition at line 27 of file Environment.php.

$parsers
protected

Definition at line 31 of file Environment.php.

$runtimeInitialized
protected

Definition at line 37 of file Environment.php.

$staging
protected

Definition at line 46 of file Environment.php.

$strictVariables
protected

Definition at line 40 of file Environment.php.

$templateClassPrefix = '__TwigTemplate_'
protected

Definition at line 43 of file Environment.php.

$tests
protected

Definition at line 34 of file Environment.php.

$unaryOperators
protected

Definition at line 41 of file Environment.php.

$visitors
protected

Definition at line 32 of file Environment.php.

const VERSION = '1.13.2'

Definition at line 19 of file Environment.php.


The documentation for this class was generated from the following file:

This documentation for Open ecommerce PEEL Shopping and PEEL.fr has been generated by Doxygen on Thu Oct 15 2015 14:41:44 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.