0

How to define global variables, global functions for controller page?

For example I need to use a variable "$idleTime" in almost all the functions of controller class. So where to define that global variable "$idleTime" in Symfony2 Framework?

3
  • What code do you have now? Commented Dec 23, 2013 at 10:08
  • 1
    You 'can try' to define it in parameters.yml... Commented Dec 23, 2013 at 10:09
  • If it's not subject to change you could hardcode it into one of your classes (Constrants::idleTime), but it would be more appropriate to do it as @Jahnux73 suggested.... Commented Dec 23, 2013 at 10:27

1 Answer 1

4

Its not a global variable but, You can define in paramters.yml a parameter

idle_time: xxx

And the in the controller:

$this->container->getParameter('idle_time');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.