$route = $app['controllers_factory'];
$route->get('{repo}/network/{commitishPath}/{page}.json',
function ($repo, $commitishPath, $page) use ($app) {
/** @var $repository Repository */
$repository = $app['git']->getRepositoryFromName($app['git.repos'], $repo);
if ($commitishPath === null) {
$commitishPath = $repository->getHead();
}
$pager = $app['util.view']->getPager($page, $repository->getTotalCommits($commitishPath));
$commits = $repository->getPaginatedCommits($commitishPath, $pager['current']);
$jsonFormattedCommits = array();
foreach ($commits as $commit) {
$detailsUrl = $app['url_generator']->generate(
'commit',
array(
'repo' => $repo,
'commit' => $commit->getHash()
)
);
$jsonFormattedCommits[$commit->getHash()] = array(
'hash' => $commit->getHash(),
'parentsHash' => $commit->getParentsHash(),
'date' => $commit->getDate()->format('U'),
'message' => htmlentities($commit->getMessage()),
'details' => $detailsUrl,
'author' => array(
'name' => $commit->getAuthor()->getName(),
'email' => $commit->getAuthor()->getEmail(),