object_type = 'file'; $file->branch = $branch; $file->branch_name = $branch->branch_name; $end = count($args) - 1; if (in_array($args[$end], array('source', 'documentation'))) { $suffix = '/' . $args[$end]; $end -= 1; } foreach ($branches as $b) { if ($b->branch_name === $args[$end]) { $branch = $b; $file->branch_name = $args[$end]; $end -= 1; break; } } $file->object_name = implode('/', array_slice($args, 0, $end + 1)); drupal_goto(api_url($file) . $suffix); }