I am trying to use Kohana 3.3 HMVC approach. I have created a view and a controller for generating a segment of a page (meant to be integrated into the actual web page by another controller and to be never accessed through HTTP from outside a controller) filled with data records retrieved through ORM. What I need is to pass some data (records selection criteria) from the top controller through the middle controller to the ORM model. Altering GET/POST data as suggested here seems wacky (as it is going to alter the whole application state rather than of the target controller as far as I understand) (but perhaps it is considered okay in the PHP world, I don't know (I am coming from the strict C++/C#/Java/Scala world), let me know if so). Is there a better way?
Asked
Active
Viewed 714 times
1 Answers
0
The HMVC approach works just like a normal request except that it has its own instance of the request class. From the HMVC sub request you can access the parent request object by loading the initial request.
$parent_request_query = $this->request->initial()->query();
You can also access the current request.
$current_request_query = $this->request->current()->query();
You could also just pass parameters.
$params = array(
'passing' => 'data'
);
echo Request::factory('controller/action')->query($params)->execute()->body()

Peter
- 2,276
- 4
- 32
- 40
$this->request->query()
. If I wanted to get to the original query params, I would use$this->request->initial()->query()
. But, Im not entirely sure if I understand what you are asking. Perhaps you can post a more detailed question. – Peter Feb 13 '14 at 01:44