Q: About twig extensions

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
GanstaZ
Registered User
Posts: 1187
Joined: Wed Oct 11, 2017 10:29 pm
Location: GZOverse

Q: About twig extensions

Post by GanstaZ »

Is it a good idea to set some data (small array) via template class and then access that data in twig extension via context or to create an extra class that will hold the data and inject it into twig extension? Any thoughts about it?
Usus est magister optimus! phpBB pre-Triton & latest php environment.
When answer lies in the question, question becomes redundant!
User avatar
mrgoldy
Former Team Member
Posts: 1394
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs
Contact:

Re: Q: About twig extensions

Post by mrgoldy »

And the data can not be send through the function / filter in the template?
Otherwise I feel like passing it through service injections in the twig extension and not through the template environment.
Keep things to only where it's needed, I suppose.
phpBB Studio / Member of the Studio

Contributing: You can do it too! Including testing Pull Requests (PR).
phpBB Development and Testing made easy.
User avatar
GanstaZ
Registered User
Posts: 1187
Joined: Wed Oct 11, 2017 10:29 pm
Location: GZOverse

Re: Q: About twig extensions

Post by GanstaZ »

No, it can not be sent that way, because it is already set in php.
Example would be:

Code: Select all

    // string or array or empty that will load all
    $tester->load(one of the above);
Load method will load what is asked and small amount of data is sent to twig extension via service injection and output can be accessed throw tag or function in template file.

Yeah.. that's what i think as well)
Usus est magister optimus! phpBB pre-Triton & latest php environment.
When answer lies in the question, question becomes redundant!
Post Reply

Return to “Extension Writers Discussion”