Created
February 21, 2011 02:42
-
-
Save dhrrgn/836601 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Controller_Blog extends Controller { | |
/** | |
* This is a simple example, the class does not exist. There are much more | |
* things you would be able to do, this is just an example. | |
* | |
* Yes, I know this is all (kind of) currently possible, but this encapsulates | |
* the response and allows for nice things like advanced response caching. | |
*/ | |
public function action_article($slug) | |
{ | |
try | |
{ | |
$article = Article::find_by_slug($slug); | |
} | |
catch (Fuel_Exception $e) | |
{ | |
return new Http_Response(new View('articles/missing'), 404); | |
} | |
$response = new Http_Response(); | |
if (Input::is_ajax()) | |
{ | |
$response->set_content(json_encode($article)); | |
$response->headers->set('Content-Type', 'application/json'); | |
} | |
else | |
{ | |
$response->set_content(new View('articles/view', array($article))); | |
} | |
return $response; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey guys,
I agree with what your both saying, how does the HMVC stuff work in Fuel, I mean surely whether your using mulitple controllers and actions shouldn't matter, the user types in one url, and they get one response back... Which is why there should only be one instance of the
Http_Request
object, which will only have one response property.(Take a look at my fork for the http_request stuff)