Question

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?

Was it helpful?

Solution

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()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top