mirror of
https://github.com/jbcr/core.git
synced 2026-04-29 19:53:08 +02:00
Don't show pages in missing locales
This commit is contained in:
committed by
Bob den Otter
parent
059c55a9dd
commit
cc750a709b
@@ -14,6 +14,7 @@ use Pagerfanta\Adapter\ArrayAdapter;
|
||||
use Pagerfanta\Pagerfanta;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class ListingController extends TwigAwareController implements FrontendZoneInterface
|
||||
@@ -41,6 +42,12 @@ class ListingController extends TwigAwareController implements FrontendZoneInter
|
||||
public function listing(ContentRepository $contentRepository, string $contentTypeSlug): Response
|
||||
{
|
||||
$contentType = ContentType::factory($contentTypeSlug, $this->config->get('contenttypes'));
|
||||
|
||||
// If the locale is the wrong locale
|
||||
if (! $contentType->get('locales')->contains($this->request->getLocale())) {
|
||||
throw new NotFoundHttpException('Content is not available in requested locale.');
|
||||
}
|
||||
|
||||
$page = (int) $this->getFromRequest('page', '1');
|
||||
$amountPerPage = $contentType->get('listing_records');
|
||||
$order = $this->getFromRequest('order', $contentType->get('order'));
|
||||
|
||||
@@ -133,6 +133,11 @@ class TwigAwareController extends AbstractController
|
||||
throw new NotFoundHttpException('Content is not viewable');
|
||||
}
|
||||
|
||||
// If the locale is the wrong locale
|
||||
if (! $record->getDefinition()->get('locales')->contains($this->request->getLocale())) {
|
||||
throw new NotFoundHttpException('Content is not available in requested locale.');
|
||||
}
|
||||
|
||||
$singularSlug = $record->getContentTypeSingularSlug();
|
||||
|
||||
$context = [
|
||||
|
||||
Reference in New Issue
Block a user