<?php

namespace Knp\Bundle\LastTweetsBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Knp\Bundle\LastTweetsBundle\Twitter\Exception\TwitterException;
use Symfony\Component\HttpFoundation\Response;

class TwitterController extends Controller
{
    public function lastTweetsAction($username, $age = null)
    {
        $twitter = $this->get('knp_last_tweets.last_tweets_fetcher');

        try {
            $tweets = $twitter->fetch($username);
        } catch (TwitterException $e) {
            $tweets = array();
        }
        
        $response = $this->render('KnpLastTweetsBundle:Tweet:lastTweets.html.twig', array(
            'username' => $username . date('H:i:s'),
            'tweets' => $tweets,
        ));

        if ($age) {
            $response->setSharedMaxAge($age);
        }
        
        return $response;
    }
}

<?php

namespace Knp\Bundle\LastTweetsBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Knp\Bundle\LastTweetsBundle\Twitter\Exception\TwitterException;
use Symfony\Component\HttpFoundation\Response;

class TwitterController extends Controller
{
    public function lastTweetsAction($username, $limit = 10, $age = null)
    {
        $twitter = $this->get('knp_last_tweets.last_tweets_fetcher');

        try {
            $tweets = $twitter->fetch($username, $limit);
        } catch (TwitterException $e) {
            $tweets = array();
        }
        
        $response = $this->render('KnpLastTweetsBundle:Tweet:lastTweets.html.twig', array(
            'username' => $username . date('H:i:s'),
            'tweets' => $tweets,
        ));

        if ($age) {
            $response->setSharedMaxAge($age);
        }
        
        return $response;
    }
}

Allow the render only a limited number of tweets
Allow the render only a limited number of tweets
