W3cubDocs

/Symfony 4.1

AppVariable

class AppVariable

Exposes some Symfony parameters and services as an "app" global variable.

Methods

setTokenStorage(TokenStorageInterface $tokenStorage)
setRequestStack(RequestStack $requestStack)
setEnvironment($environment)
setDebug($debug)
TokenInterface|null getToken()

Returns the current token.

mixed getUser()

Returns the current user.

Request|null getRequest()

Returns the current request.

Session|null getSession()

Returns the current session.

string getEnvironment()

Returns the current app environment.

bool getDebug()

Returns the current app debug mode.

array getFlashes($types = null)

Returns some or all the existing flash messages: * getFlashes() returns all the flash messages * getFlashes('notice') returns a simple array with flash messages of that type * getFlashes(array('notice', 'error')) returns a nested array of type => messages.

Details

setTokenStorage(TokenStorageInterface $tokenStorage)

Parameters

TokenStorageInterface $tokenStorage

setRequestStack(RequestStack $requestStack)

Parameters

RequestStack $requestStack

setEnvironment($environment)

Parameters

$environment

setDebug($debug)

Parameters

$debug

TokenInterface|null getToken()

Returns the current token.

Return Value

TokenInterface|null

Exceptions

RuntimeException When the TokenStorage is not available

mixed getUser()

Returns the current user.

Return Value

mixed

See also

TokenInterface::getUser

Request|null getRequest()

Returns the current request.

Return Value

Request|null The HTTP request object

Session|null getSession()

Returns the current session.

Return Value

Session|null The session

string getEnvironment()

Returns the current app environment.

Return Value

string The current environment string (e.g 'dev')

bool getDebug()

Returns the current app debug mode.

Return Value

bool The current debug mode

array getFlashes($types = null)

Returns some or all the existing flash messages: * getFlashes() returns all the flash messages * getFlashes('notice') returns a simple array with flash messages of that type * getFlashes(array('notice', 'error')) returns a nested array of type => messages.

Parameters

$types

Return Value

array

© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Bridge/Twig/AppVariable.html