-
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
a2ba9fb
commit 7fafc05
Showing
6 changed files
with
146 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Controller\Website; | ||
|
||
use App\Repository\EventRepository; | ||
use App\Repository\LocationRepository; | ||
use Sulu\Bundle\WebsiteBundle\Controller\DefaultController; | ||
use Sulu\Component\Content\Compat\StructureInterface; | ||
|
||
class EventOverviewController extends DefaultController | ||
{ | ||
protected function getAttributes($attributes, StructureInterface $structure = null, $preview = false) | ||
{ | ||
/** @var EventRepository $eventRepository */ | ||
$eventRepository = $this->container->get(EventRepository::class); | ||
/** @var LocationRepository $locationRepository */ | ||
$locationRepository = $this->container->get(LocationRepository::class); | ||
|
||
$request = $this->getRequest(); | ||
$locationId = $request->query->get('location'); | ||
|
||
$attributes = parent::getAttributes($attributes, $structure, $preview); | ||
$attributes['events'] = $eventRepository->filterByLocationId( | ||
$locationId ? (int) $locationId : null, | ||
$request->getLocale(), | ||
); | ||
$attributes['locations'] = $locationRepository->findAll(); | ||
|
||
return $attributes; | ||
} | ||
|
||
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