This is the dashboard controller code in PHP Symfony 2. It collects some aggregate data and points for charts, but i don't like it very much. Do you think that this code belongs to what a controller should do in a MVC patter? How can i refactor it?
public function dashboardAction()
{
$bag = array();
// Helpers from service container
$messaging = $this->get('messaging.helper');
$charting = $this->get('charting.helper');
// Current logged user, subscription and message inhibitor
$loggedUser = $this->getSecurityContext()->getToken()->getUser();
$subscription = $messaging->createSubscriptionFromUser($loggedUser);
$usage = $messaging->createUsageFromSubscription($subscription);
$bag['subscription'] = $subscription;
$bag['usage'] = $usage;
$bag['inhibitor'] = $messaging->createInhibitor($usage, $subscription);
// Get charts from usage raw data
$rawData = $usage->getRawData();
$start = $usage->getStartDate();
$end = $usage->getEndDate();
$bag['line_chart'] = $charting->createMessagesLineChart($rawData, $start, $end);
$bag['pie_chart'] = $charting->createMessagesPieChart($rawData);
// Customers and latest 5 added
$customers = $loggedUser->getCustomers();
$bag['customers_count'] = $customers->count();
$bag['latest_customers'] = $customers->slice(0, 5);
// Tags/keywords counts and latest 5 meta
$metas = $loggedUser->getMeta();
$getTags = function($m) { return $m instanceof Tag; };
$getKeywords = function($m) { return $m instanceof Keyword; };
$bag['tags_count'] = $metas->filter($getTags)->count();
$bag['keywords_count'] = $metas->filter($getKeywords)->count();
$bag['latest_meta'] = $metas->slice(0, 5);
// SMS and newsletter counts
$outgoingMessages = $loggedUser->getOutgoingMessages();
$getSms = function($m) { return $m instanceof SmallTextMessage; };
$getNewsletters = function($m) { return $m instanceof Newsletter; };
$bag['sms_count'] = $outgoingMessages->filter($getSms)->count();
$bag['newsletter_count'] = $outgoingMessages->filter($getNewsletters)->count();
return $bag;
}