How to pass parameters from Router FILTER_IN function into Presenter?
- petroff
- Member | 5
Hi there, would somebody help me with this please?
I am using FILTER_IN function in Router to look in database for a presenter
related to current URL.
For example:
www.domain.com/some-category/ is treated by presenter –
category. There are other information also stored in the database (like Title,
Description of page – all managed by users) what I’d like to pass into
Presenter – category.
Then at the end I need to access the original some-category to perform
FILTER_OUT function.
Can you please advice where and how to store such data?
Many thanks for your help!
Router with FILTER_IN function Process
FILTER_IN function ‚getpresin‘ is reading database ‘process’ to obtain presenter – ‘ProcessPres’ and this is returned back to router. Works fine.
In the method – ‘getpresin’ I need to save somewhere other information from ‘process’ file like ‘ProcessPres’, ‘ProcessTitle', 'ProcessDesc’… to be able to access it in presenter.
And finally at the end I need to have again original ‘ProcessPres’ value available in FILTER_OUT function – ‘getpresout’ – to be able to route back to /some-category/
- petr.pavel
- Member | 535
Calls to FILTER_IN and FILTER_OUT must work independently. You can't assume FILTER_IN will be called before FILTER_OUT. Think of a link in a page. No FILTER_IN, just FILTER_OUT. (I hope I'm not confusing the two.)
What info do you need in your FILTER_OUT function?
As for accessing a db result fetched in FILTER_IN also in presenter:
- Define method getById() in say, ProcessModel class.
- Implement caching into getById() (e.g. using a static variable / array with id as the index).
- Use $processModel->getById() in both your FILTER_IN function and the presenter.