@@ -35,49 +35,49 @@ |
||
| 35 | 35 | class ListController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController |
| 36 | 36 | { |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * golfCourseRepository |
|
| 40 | - * |
|
| 41 | - * @var \TNM\GolfCourses\Domain\Repository\GolfCourseRepository |
|
| 42 | - * @inject |
|
| 43 | - */ |
|
| 44 | - protected $golfCourseRepository = null; |
|
| 38 | + /** |
|
| 39 | + * golfCourseRepository |
|
| 40 | + * |
|
| 41 | + * @var \TNM\GolfCourses\Domain\Repository\GolfCourseRepository |
|
| 42 | + * @inject |
|
| 43 | + */ |
|
| 44 | + protected $golfCourseRepository = null; |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @var \SJBR\StaticInfoTables\Domain\Repository\CountryRepository |
|
| 48 | - * @inject |
|
| 49 | - */ |
|
| 50 | - protected $countryRepository = null; |
|
| 46 | + /** |
|
| 47 | + * @var \SJBR\StaticInfoTables\Domain\Repository\CountryRepository |
|
| 48 | + * @inject |
|
| 49 | + */ |
|
| 50 | + protected $countryRepository = null; |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * action list |
|
| 54 | - * |
|
| 55 | - * @return void |
|
| 56 | - */ |
|
| 57 | - public function listAction() |
|
| 58 | - { |
|
| 59 | - $countryAndCourses = []; |
|
| 60 | - $coursesTotal = 0; |
|
| 61 | - $countriesUidsInUse = $this->golfCourseRepository->findCountriesUidsInUse(); |
|
| 52 | + /** |
|
| 53 | + * action list |
|
| 54 | + * |
|
| 55 | + * @return void |
|
| 56 | + */ |
|
| 57 | + public function listAction() |
|
| 58 | + { |
|
| 59 | + $countryAndCourses = []; |
|
| 60 | + $coursesTotal = 0; |
|
| 61 | + $countriesUidsInUse = $this->golfCourseRepository->findCountriesUidsInUse(); |
|
| 62 | 62 | |
| 63 | - foreach ($countriesUidsInUse as $countryUid) { |
|
| 64 | - /** @var Country $country */ |
|
| 65 | - $country = $this->countryRepository->findByUid($countryUid); |
|
| 66 | - $countryName = $country->getShortNameEn(); |
|
| 67 | - $coursesInCountry = $this->golfCourseRepository->findAllInCountry($countryUid); |
|
| 68 | - if(!count($coursesInCountry)) { |
|
| 69 | - continue; |
|
| 70 | - } |
|
| 71 | - $countryAndCourses[$countryName]['name'] = $countryName; |
|
| 72 | - /** @var GolfCourse $course */ |
|
| 73 | - foreach ($coursesInCountry as $course) { |
|
| 74 | - $countryAndCourses[$countryName]['courses'][$course->getUid()] = $course; |
|
| 75 | - $coursesTotal++; |
|
| 76 | - } |
|
| 77 | - } |
|
| 63 | + foreach ($countriesUidsInUse as $countryUid) { |
|
| 64 | + /** @var Country $country */ |
|
| 65 | + $country = $this->countryRepository->findByUid($countryUid); |
|
| 66 | + $countryName = $country->getShortNameEn(); |
|
| 67 | + $coursesInCountry = $this->golfCourseRepository->findAllInCountry($countryUid); |
|
| 68 | + if(!count($coursesInCountry)) { |
|
| 69 | + continue; |
|
| 70 | + } |
|
| 71 | + $countryAndCourses[$countryName]['name'] = $countryName; |
|
| 72 | + /** @var GolfCourse $course */ |
|
| 73 | + foreach ($coursesInCountry as $course) { |
|
| 74 | + $countryAndCourses[$countryName]['courses'][$course->getUid()] = $course; |
|
| 75 | + $coursesTotal++; |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - $this->view->assign('countryAndCourses', $countryAndCourses); |
|
| 80 | - $this->view->assign('coursesCount', $coursesTotal); |
|
| 81 | - $this->view->assign('countriesCount', count($countryAndCourses)); |
|
| 82 | - } |
|
| 79 | + $this->view->assign('countryAndCourses', $countryAndCourses); |
|
| 80 | + $this->view->assign('coursesCount', $coursesTotal); |
|
| 81 | + $this->view->assign('countriesCount', count($countryAndCourses)); |
|
| 82 | + } |
|
| 83 | 83 | } |
| 84 | 84 | \ No newline at end of file |
@@ -65,7 +65,7 @@ |
||
| 65 | 65 | $country = $this->countryRepository->findByUid($countryUid); |
| 66 | 66 | $countryName = $country->getShortNameEn(); |
| 67 | 67 | $coursesInCountry = $this->golfCourseRepository->findAllInCountry($countryUid); |
| 68 | - if(!count($coursesInCountry)) { |
|
| 68 | + if (!count($coursesInCountry)) { |
|
| 69 | 69 | continue; |
| 70 | 70 | } |
| 71 | 71 | $countryAndCourses[$countryName]['name'] = $countryName; |
@@ -36,42 +36,42 @@ |
||
| 36 | 36 | class GolfCourseRepository extends \TYPO3\CMS\Extbase\Persistence\Repository |
| 37 | 37 | { |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @param $countryUid |
|
| 41 | - * |
|
| 42 | - * @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface |
|
| 43 | - */ |
|
| 44 | - public function findAllInCountry($countryUid) |
|
| 45 | - { |
|
| 46 | - /** @var QueryInterface $query */ |
|
| 47 | - $query = $this->createQuery(); |
|
| 39 | + /** |
|
| 40 | + * @param $countryUid |
|
| 41 | + * |
|
| 42 | + * @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface |
|
| 43 | + */ |
|
| 44 | + public function findAllInCountry($countryUid) |
|
| 45 | + { |
|
| 46 | + /** @var QueryInterface $query */ |
|
| 47 | + $query = $this->createQuery(); |
|
| 48 | 48 | |
| 49 | - $querySettings = $query->getQuerySettings(); |
|
| 50 | - $querySettings->setRespectStoragePage(false); |
|
| 51 | - $querySettings->setIgnoreEnableFields(false); |
|
| 49 | + $querySettings = $query->getQuerySettings(); |
|
| 50 | + $querySettings->setRespectStoragePage(false); |
|
| 51 | + $querySettings->setIgnoreEnableFields(false); |
|
| 52 | 52 | |
| 53 | - $query->matching($query->equals('country', $countryUid)); |
|
| 54 | - $query->setOrderings(['name' => 'ASC']); |
|
| 55 | - $query->setQuerySettings($querySettings); |
|
| 53 | + $query->matching($query->equals('country', $countryUid)); |
|
| 54 | + $query->setOrderings(['name' => 'ASC']); |
|
| 55 | + $query->setQuerySettings($querySettings); |
|
| 56 | 56 | |
| 57 | - return $query->execute(); |
|
| 58 | - } |
|
| 57 | + return $query->execute(); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * @return array |
|
| 62 | - */ |
|
| 63 | - public function findCountriesUidsInUse() |
|
| 64 | - { |
|
| 65 | - $uids = []; |
|
| 66 | - $courses = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
| 67 | - 'DISTINCT country', |
|
| 68 | - 'tx_golfcourses_domain_model_golfcourse' |
|
| 69 | - ); |
|
| 60 | + /** |
|
| 61 | + * @return array |
|
| 62 | + */ |
|
| 63 | + public function findCountriesUidsInUse() |
|
| 64 | + { |
|
| 65 | + $uids = []; |
|
| 66 | + $courses = $GLOBALS['TYPO3_DB']->exec_SELECTquery( |
|
| 67 | + 'DISTINCT country', |
|
| 68 | + 'tx_golfcourses_domain_model_golfcourse' |
|
| 69 | + ); |
|
| 70 | 70 | |
| 71 | - foreach ($courses as $course) { |
|
| 72 | - $uids[] = $course['country']; |
|
| 73 | - } |
|
| 71 | + foreach ($courses as $course) { |
|
| 72 | + $uids[] = $course['country']; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - return $uids; |
|
| 76 | - } |
|
| 75 | + return $uids; |
|
| 76 | + } |
|
| 77 | 77 | } |
| 78 | 78 | \ No newline at end of file |