ModelBundle/Repository/ContentRepository.php
protected function generateLastVersionFilter(Stage $qa, array $order=array())
    {
        $group = array(
            '_id' => array('contentId' => '$contentId'),
            self::ALIAS_FOR_GROUP => array('$last' => '$$ROOT'),
        );

        foreach ($order as $column => $orderDirection) {
            $group[str_replace('.', '_', $column)] = array('$last' => '$' . $column);
        }

        $qa->sort(array('createdAt' => 1));
        $qa->group($group);

        return $qa;
    }
protected function generateLastVersionFilter(Stage $qa, array $order=array())
    {
        $group = array(
            '_id' => array('contentId' => '$contentId'),
            self::ALIAS_FOR_GROUP => array('$last' => '$$ROOT'),
        );

        foreach ($order as $column => $orderDirection) {
            $group[str_replace('.', '_', $column)] = array('$last' => '$' . $column);
        }

        $qa->sort(array('createdAt' => 1));
        $qa->group($group);

        return $qa;
    }
@param Stage $qa
@param array $order

@return Stage