TIP: Use Markdown or, <pre> for multi line code blocks / <code> for inline code.
These forums are read-only and for archival purposes only!
Please join our new forums at discourse.kohanaframework.org
internal request call other class and its method and passing a value
  • Hi is there anyway to pass the value other than session in an internal request? consider the code below, I just want to pass a value to user class and its test method

  • Request::factory('user/test')->method(Request::POST)->post($post)->execute();


  • @WinterSilence

    thank you its now working, but the challenge now is it is not returning value as expected. in the "('user/test')" controller/method, I created a return integer value however the integer value is not showing up as expected. Instead it shows up an object see the object below

    object(Response)#17 (5) { ["_status":protected]=> int(200) ["_header":protected]=> object(HTTP_Header)#18 (5) { ["_accept_content":protected]=> NULL ["_accept_charset":protected]=> NULL ["_accept_encoding":protected]=> NULL ["_accept_language":protected]=> NULL ["storage":"ArrayObject":private]=> array(0) { } } ["_body":protected]=> string(0) "" ["_cookies":protected]=> array(0) { } ["_protocol":protected]=> NULL } 

    I didn't get the integer return, why is it? Instead the return is an object.

  • You are executing an emulated HTTP Request, which results in a Response object. You can get the body of said object with Request::body() like so:

    $response = Request::factory('user/test')->query($get)->execute(); // Just a guess, using the POST version doesn't change anything
    $int = unserialize($response->body()); // use the body of the emulated HTTP request's response however you want

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion