How to define Global Variables

Notice: This thread is very old.
jefflee
Member | 1
+
0
-

Hello,

How can I define global variables for all presenters and for my own classes?
I need to define many parameters to config my application.

Thanks,

Jeff

mkoubik
Member | 728
+
0
-

In config.neon:

parameters:
	foo: 'Hello world!'

In presenter you can access it by $this->context->parameters['foo'], or even better by registering presenter as a service (see below).
In your own services, you can pass parameters to constructor:

class MyService
{
	private $foo;

	public function __construct($foo)
	{
		$this->foo = $foo;
	}
}

config.neon:

services:
	- MyService(%foo%)