Set Variable in Twig Extension Class


I’m currently writing a Plugin which parses an ics (calendar-) File and creates an events list which is made available via a twig variable, according to .
This works ok so far (with hardcoded values), but now I want to pass variable value(s) to my TwigExtension Class.
Unfortunately, there seems to be no way, so far.
Normally, I would have a class like
class Testclass
private $testvar = “default value”;
public function setTestvar($testvar) {
$this->testvar = $testvar;
$Testclass = new Testclass();
// now pass a value to $testvar in Testclass:
$Testclass->setTestvar(“another value”);

but I can’t see how this could be done with my TwigExtension, which is initialized like this:
$this->grav[‘twig’]->twig->addExtension(new EventListTwigExtension());

anyone got a hint for me ?


ok, solved :wink:
I had to:

  • create new TwigExtension Object $ext
  • set desired variable Value
  • then add Extension: $this->grav[‘twig’]->twig->addExtension($ext);

-> ok.