Skip to content

Commit

Permalink
🐛 Update MapperController.php
Browse files Browse the repository at this point in the history
  • Loading branch information
jbelien committed Dec 3, 2022
1 parent 234482e commit 3570d0c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Controller/App/MapperController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ public function __construct(
#[Route('/{regionKey}/mapper/{id}', name: 'app_mapper', requirements: ['regionKey' => '[\w\-_]+'])]
#[Route('/{continent}/{regionKey}/mapper/{id}', name: 'app_mapper_full', requirements: ['continent' => 'asia|africa|australia|europe|north-america|south-america', 'regionKey' => '[\w\-_]+'])]
#[IsGranted('ROLE_USER')]
public function index(Request $request, Mapper $mapper, string $regionKey, ?string $continent): Response
public function index(Request $request, string $regionKey, int $id, ?string $continent): Response
{
$region = $this->provider->getRegion($continent, $regionKey);

$this->mapper = $mapper;
$this->mapper = $this->entityManager->find(Mapper::class, $id);

$mapperRegions = array_map(fn (Region $region) => $region->getId(), $this->mapper->getRegion()->toArray());

Expand Down Expand Up @@ -76,7 +76,7 @@ public function index(Request $request, Mapper $mapper, string $regionKey, ?stri
$firstChangetsetCreatedAt = array_map(fn (Mapper $mapper): ?\DateTimeImmutable => $mapper->getFirstChangeset()->getCreatedAt(), $mappers);
array_multisort($firstChangetsetCreatedAt, \SORT_DESC, $mappers);

$current = array_search($mapper, $mappers, true);
$current = array_search($this->mapper, $mappers, true);
$prev = $current > 0 ? $mappers[$current - 1] : null;
$next = $current < (\count($mappers) - 1) ? $mappers[$current + 1] : null;

Expand Down

0 comments on commit 3570d0c

Please sign in to comment.