Hello! Do not tell me how to contact other controllers in Kohana 3.3. I do this:

class Controller_Main extends Controller_Template { public $template = 'static'; public function action_index() { $countries = Request::factory('place/country')->execute(); //print_r($response); } } class Controller_Place extends Controller { public function action_country() { $location = new Model_Location(); return $location->get_countries(); } } class Model_Location extends Model { public function get_countries() { return DB::select('name','country_id') ->from('countries') ->order_by('country_id') ->execute()->as_array(); } public function get_country_regions($country_id) { } } 

But when printing out the following information:

 Response Object ( [_status:protected] => 200 [_header:protected] => HTTP_Header Object ( [_accept_content:protected] => [_accept_charset:protected] => [_accept_encoding:protected] => [_accept_language:protected] => [storage:ArrayObject:private] => Array ( ) ) [_body:protected] => [_cookies:protected] => Array ( ) [_protocol:protected] => HTTP/1.1 ) 
  • And why do you need from one controller to apply to another? These are two different entities. Which controller / action to address decides routing. Inheritance is allowed, for example, TopNewsController extends NewsController . All other connections should occur at the model level. - romeo
  • one
    The @romeo HMVC is an approach in which the final page can be formed from the output of several controllers. - etki
  • @Etki: Thank you, refreshed your knowledge. - romeo
  • In older versions, after execute (), they were also addressed to response. Google displays links to articles from 2011-2012. Therefore, I did not find a solution to the problem - murash
  • @murash: And what var_dump(Request::factory('place/country')->execute()->__toString()); prints var_dump(Request::factory('place/country')->execute()->__toString()); ? Must display the Response object's body. - romeo

1 answer 1

Kohana allows you to use your classes from anywhere. (The basic principle of MVC).

Kohana loads the classes by the file name if the file (path) is not correct. The name of the Kohana class will drop it as an external code.

As for example the class: Kohana Controller_V1_Api_User will search in: application / classes / Controller / V1 / Api / User.php

There are a number of conditions for the location of classes. It is also important to know that the Kahan should load any class that will be located in the kohana folder *

For example: application / classes / Kohana / TestClass.php