When I try to set a class property from the parameterBag in the class constructor, like so:
public function __construct()
{
$this->foo = $this->getParameter('app.foo');
}
I get
Call to a member function has() on null
I wonder if it’s possible to access parameters defined in config/services.yaml in the constructor of a controller ?
I don’t know symfony, but from my experience with other programming languages I think the problem is not so much accessing the parameters, but assigning them to a variable pointed to by $this. The construction of the controller is not yet finished, so $this is probably invalid.