Created
April 23, 2014 10:59
-
-
Save trikitrok/c8941daa5fa956de2676 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CoursesController | |
{ | |
private $coursesView; | |
private $courseCategoriesRepository; | |
private $courseProgramsRepository; | |
private $coursesToViewData; | |
public function __construct( | |
$coursesView, | |
$courseCategoriesRepository, | |
$courseProgramsRepository, | |
$coursesToViewData | |
) { | |
$this->courseCategoriesRepository = $courseCategoriesRepository; | |
$this->courseProgramsRepository = $courseProgramsRepository; | |
$this->coursesView = $coursesView; | |
$this->coursesToViewData = $coursesToViewData; | |
} | |
public function listCourses($categoryName) | |
{ | |
$courseProgramsData = $this->getCourseProgramsData($categoryName); | |
return $this->coursesView->render($courseProgramsData, $categoryName); | |
} | |
private function getCourseProgramsData($categoryName) | |
{ | |
$categoryId = $this->courseCategoriesRepository->getIdForCategoryWithName($categoryName); | |
$coursePrograms = $this->courseProgramsRepository->getAllWithCourseCategoryId($categoryId); | |
return $this->coursesToViewData->translate($coursePrograms, $categoryName); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment