-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
12 - Add a location filter to the events overview page
- Loading branch information
1 parent
102b1e7
commit 7377396
Showing
7 changed files
with
165 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Controller; | ||
|
||
use App\Repository\EventRepository; | ||
use App\Repository\LocationRepository; | ||
use Sulu\Bundle\WebsiteBundle\Controller\WebsiteController; | ||
use Sulu\Component\Content\Compat\StructureInterface; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class EventOverviewController extends WebsiteController | ||
{ | ||
public function indexAction( | ||
Request $request, | ||
StructureInterface $structure, | ||
bool $preview = false, | ||
bool $partial = false | ||
): Response { | ||
/** @var EventRepository $eventRepository */ | ||
$eventRepository = $this->get(EventRepository::class); | ||
/** @var LocationRepository $locationRepository */ | ||
$locationRepository = $this->get(LocationRepository::class); | ||
|
||
$locationId = $request->query->get('location'); | ||
if ('' === $locationId) { | ||
$locationId = null; | ||
} | ||
|
||
$response = $this->renderStructure( | ||
$structure, | ||
[ | ||
'events' => $eventRepository->filterByLocationId( | ||
(int) $locationId, | ||
$request->getLocale() | ||
), | ||
'locations' => $locationRepository->findAll(), | ||
], | ||
$preview, | ||
$partial | ||
); | ||
|
||
return $response; | ||
} | ||
|
||
/** | ||
* @return mixed[] | ||
*/ | ||
public static function getSubscribedServices(): array | ||
{ | ||
return array_merge( | ||
parent::getSubscribedServices(), | ||
[ | ||
EventRepository::class, | ||
LocationRepository::class, | ||
] | ||
); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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