Chaining response in Kohana fails with undefined property exception
I can't seem to chain some actions together, specifically this line of code:
$messages开发者_开发知识库 = Request::factory('messages/get_messages')->execute()->response;
When I play this in my browser, Kohana fails with the following warning.
ErrorException [ Notice ]: Undefined property: Response::$response
The full line of code for this reads...
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Profile extends Controller_Application
{
public function action_index()
{
$content = View::factory('profile/public')
->set('username', 'Test User')
->bind('messages', $messages);
$messages = Request::factory('messages/get_messages')->execute()->response;
$this->template->content = $content;
}
}
Since I've been going through Beginners Guide by Jason D. Straughan, there have been a few little differences that I've been able to resolve but drawing a blank on this. Any pointers here would be appreciated.
This line of code is on page 81 of the book (jump to page 96 on the scribd viewer).
Try using:
$messages = Request::factory('messages/get_messages')->execute()->body();
The reason you get the Notice error
is that the object Response
(which is returned by Request::factory(...)->execute()
) has no property called $response
( Kohana Docs 3.1 | Response OR Kohana Docs 3.2 | Response ).
精彩评论