Skip to content

Instantly share code, notes, and snippets.

@matheuslc
Created March 5, 2016 00:10
Show Gist options
  • Save matheuslc/dfffabdcdd894e349d60 to your computer and use it in GitHub Desktop.
Save matheuslc/dfffabdcdd894e349d60 to your computer and use it in GitHub Desktop.
DashboardController.php
/**
* @Route(
* "/e/{schoolId}/",
* requirements={"schoolId" = "\d+"},
* name="school_redirect"
* )
* @Method({"GET"})
*/
public function schoolRedirectAction(Request $request, $schoolId)
{
$year = $request->query->get('year', 2014);
$school = $this->get('school.locator')
->findById($schoolId);
$edition = $this->get('school.access')->getLastEditionSchoolHasAccess($school);
if ($edition) {
$participation = $this->get('participation.locator')
->findBySchoolAndYear($school->getId(), $edition->getYear());
return $this->redirect(
$this->generateUrl(
'dashboard',
[
'participationId' => $participation->getId()
]
)
);
}
return $this->render('AppBundle:Dashboard:schoolPlanError.html.twig');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment