Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/Menu/FrontendMenuBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Bolt\Collection\DeepCollection;
use Bolt\Configuration\Config;
use Bolt\Configuration\Content\ContentType;
use Bolt\Entity\Content;
use Bolt\Repository\ContentRepository;
use Bolt\Twig\ContentExtension;
Expand Down Expand Up @@ -96,15 +97,16 @@ private function generateUri(string $link = ''): array

private function getContent(string $link): ?Content
{
$parts = explode('/', $link);
[$contentTypeSlug, $slug] = explode('/', $link);

// First, try to get it if the id is numeric.
if (is_numeric($parts[1])) {
return $this->contentRepository->findOneById((int) $parts[1]);
if (is_numeric($slug)) {
return $this->contentRepository->findOneById((int) $slug);
}

// Otherwise fetch it by getting it from the slug
// @todo it should check content type slug too
return $this->contentRepository->findOneBySlug($parts[1]);
/** @var ContentType $contentType */
$contentType = $this->config->getContentType($contentTypeSlug);

return $this->contentRepository->findOneBySlug($slug, $contentType);
}
}