Twig_Sandbox_SecurityNotAllowedFunctionError

Extends\Twig\Sandbox\SecurityNotAllowedFunctionError

Exception thrown when a not allowed function is used in a template.

This exception class and its children must only be used when an error occurs during the loading of a template, when a syntax error is detected in a template, or when rendering a template. Other errors must use regular PHP exception classes (like when the template cache directory is not writable for instance).

To help debugging template issues, this class tracks the original template name and line where the error occurred.

Whenever possible, you must set these information (original template name and line number) yourself by passing them to the constructor. If some or all these information are not available from where you throw the exception, then this class will guess them automatically (when the line number is set to -1 and/or the name is set to null). As this is a costly operation, this can be disabled by passing false for both the name and the line number when creating a new instance of this class.

package

Default

Methods

Constructor.

__construct(string $message,integer $lineno = -1,\Twig\Source|string|null $source = null,\Exception $previous = null)
inherited

Set the line number to -1 to enable its automatic guessing. Set the name to null to enable its automatic guessing.

Arguments

$message

string

The error message

$lineno

integer

The template line where the error occurred

$source

\Twig\Source|string|null

The source context where the error occurred

$previous

\Exception

The previous exception

appendMessage

appendMessage( $rawMessage)
inherited

Arguments

$rawMessage

getFunctionName

getFunctionName()
inherited

Gets the raw message.

getRawMessage(): string
inherited

Response

string

The raw message

Gets the source context of the Twig template where the error occurred.

getSourceContext(): \Twig\Source|null
inherited

Response

\Twig\Source|null

Gets the logical name where the error occurred.

getTemplateFile(): string
inherited
deprecated

since 1.27 (to be removed in 2.0). Use getSourceContext() instead.

Response

string

The name

Gets the template line where the error occurred.

getTemplateLine(): integer
inherited

Response

integer

The template line

Gets the logical name where the error occurred.

getTemplateName(): string
inherited
deprecated

since 1.29 (to be removed in 2.0). Use getSourceContext() instead.

Response

string

The name

guess

guess()
inherited

Sets the source context of the Twig template where the error occurred.

setSourceContext(\Twig\Source $source = null)
inherited

Arguments

$source

\Twig\Source

Sets the logical name where the error occurred.

setTemplateFile(string $name)
inherited
deprecated

since 1.27 (to be removed in 2.0). Use setSourceContext() instead.

Arguments

$name

string

The name

Sets the template line where the error occurred.

setTemplateLine(integer $lineno)
inherited

Arguments

$lineno

integer

The template line

Sets the logical name where the error occurred.

setTemplateName(string $name)
inherited
deprecated

since 1.29 (to be removed in 2.0). Use setSourceContext() instead.

Arguments

$name

string

The name

Properties

functionName

functionName :
inherited

Type(s)

lineno

lineno :
inherited

Type(s)

filename

filename :
inherited

Type(s)

rawMessage

rawMessage :
inherited

Type(s)

sourcePath

sourcePath :
inherited

Type(s)

sourceCode

sourceCode :
inherited

Type(s)