public function onKernelException(ExceptionEvent $event): void
{
$throwable = $event->getThrowable();
if ($throwable instanceof NotValidCurrentPageException) {
$event->setThrowable(new NotFoundHttpException('Page Not Found', $throwable));
}
}
}
$this->called = true;
$this->priority ??= $dispatcher->getListenerPriority($eventName, $this->listener);
$e = $this->stopwatch->start($this->name, 'event_listener');
($this->optimizedListener ?? $this->listener)($event, $eventName, $dispatcher);
if ($e->isStarted()) {
$e->stop();
}
foreach ($listeners as $listener) {
if ($stoppable && $event->isPropagationStopped()) {
break;
}
$listener($event, $eventName, $this);
}
}
/**
* Sorts the internal list of listeners for the given event by priority.
} else {
$listeners = $this->getListeners($eventName);
}
if ($listeners) {
$this->callListeners($listeners, $eventName, $event);
}
return $event;
}
try {
$this->beforeDispatch($eventName, $event);
try {
$e = $this->stopwatch->start($eventName, 'section');
try {
$this->dispatcher->dispatch($event, $eventName);
} finally {
if ($e->isStarted()) {
$e->stop();
}
}
* Handles a throwable by trying to convert it to a Response.
*/
private function handleThrowable(\Throwable $e, Request $request, int $type): Response
{
$event = new ExceptionEvent($this, $request, $type, $e);
$this->dispatcher->dispatch($event, KernelEvents::EXCEPTION);
// a listener might have replaced the exception
$e = $event->getThrowable();
if (!$event->hasResponse()) {
$this->finishRequest($request, $type);
throw $e;
}
return $this->handleThrowable($e, $request, $type);
} finally {
$this->requestStack->pop();
}
}
$this->boot();
++$this->requestStackSize;
$this->resetServices = true;
try {
return $this->getHttpKernel()->handle($request, $type, $catch);
} finally {
--$this->requestStackSize;
}
}
$this->request = $request;
}
public function run(): int
{
$response = $this->kernel->handle($this->request);
$response->send();
if ($this->kernel instanceof TerminableInterface) {
$this->kernel->terminate($this->request, $response);
}
$app = $app(...$args);
exit(
$runtime
->getRunner($app)
->run()
);
<?php
use App\Kernel;
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
return function (array $context) {
return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
};
{
if ($this->getNormalizeOutOfRangePages()) {
return $this->getNbPages();
}
throw new OutOfRangeCurrentPageException(sprintf('Page "%d" does not exist. The currentPage must be inferior to "%d"', $currentPage, $this->getNbPages()));
}
private function resetForCurrentPageChange(): void
{
$this->currentPageResults = null;
* @phpstan-return positive-int
*/
private function filterOutOfRangeCurrentPage(int $currentPage): int
{
if ($this->notAllowedCurrentPageOutOfRange($currentPage)) {
return $this->normalizeOutOfRangeCurrentPage($currentPage);
}
return $currentPage;
}
*/
private function filterCurrentPage(int $currentPage): int
{
$this->checkCurrentPage($currentPage);
return $this->filterOutOfRangeCurrentPage($currentPage);
}
/**
* @throws LessThan1CurrentPageException if the current page is less than 1
*/
* @throws LessThan1CurrentPageException if the current page is less than 1
* @throws OutOfRangeCurrentPageException if It is not allowed out of range pages and they are not normalized
*/
public function setCurrentPage(int $currentPage): PagerfantaInterface
{
$this->currentPage = $this->filterCurrentPage($currentPage);
$this->resetForCurrentPageChange();
return $this;
}
private function getPaginator($queryBuilder, $currentPage) {
$adapter = new QueryAdapter($queryBuilder);
$paginator = new Pagerfanta($adapter);
$paginator->setMaxPerPage(40);
$paginator->setCurrentPage($currentPage);
return $paginator;
}
public function findLatest($page) {
return $this->getPaginator($this->createQueryBuilder('r')->where('r.enabled = true'), $page);
foreach ($terms as $key => $term) {
$queryBuilder->andWhere('r.title LIKE :term' . $key);
$queryBuilder->setParameter('term' . $key, '%' . $term. '%');
}
}
return $this->getPaginator($queryBuilder, $page);
}
public function findNumberOfRecipes() {
return $this->getBasicQueryBuilder()
->select('count(r.id)')
$response = $this->handleUglyTerm($request->query->get("q"), "blogWithTerm", array("blogSlug" => $blogSlug));
}
return $response ??
$this->render('recipe/list.html.twig', [
'recipes' => $this->em->getRepository(Recipe::class)->findRecipeListForCriterias($request->query->get("page", 1), $categorySlug, $blogSlug, $term),
'term' => str_replace('+', ' ', $term),
'searchPlaceholder' => "blub",
'categories' => $this->getCategoryList('blogWithCategory', array('blogSlug' => $blog->getSlug())),
'pageTextElements' => $this->getPageTextElements($request->query->get("page", 1), $category, $blog, $term)
]);
$this->dispatcher->dispatch($event, KernelEvents::CONTROLLER_ARGUMENTS);
$controller = $event->getController();
$arguments = $event->getArguments();
// call controller
$response = $controller(...$arguments);
// view
if (!$response instanceof Response) {
$event = new ViewEvent($this, $request, $type, $response, $event);
$this->dispatcher->dispatch($event, KernelEvents::VIEW);
{
$request->headers->set('X-Php-Ob-Level', (string) ob_get_level());
$this->requestStack->push($request);
try {
return $this->handleRaw($request, $type);
} catch (\Throwable $e) {
if ($e instanceof \Error && !$this->handleAllThrowables) {
throw $e;
}
$this->boot();
++$this->requestStackSize;
$this->resetServices = true;
try {
return $this->getHttpKernel()->handle($request, $type, $catch);
} finally {
--$this->requestStackSize;
}
}
$this->request = $request;
}
public function run(): int
{
$response = $this->kernel->handle($this->request);
$response->send();
if ($this->kernel instanceof TerminableInterface) {
$this->kernel->terminate($this->request, $response);
}
$app = $app(...$args);
exit(
$runtime
->getRunner($app)
->run()
);
<?php
use App\Kernel;
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
return function (array $context) {
return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
};
No log messages
[2/2]
NotFoundHttpException
|
---|
Symfony\Component\HttpKernel\Exception\NotFoundHttpException: Page Not Found at vendor/babdev/pagerfanta-bundle/src/EventListener/ConvertNotValidCurrentPageToNotFoundListener.php:16 at BabDev\PagerfantaBundle\EventListener\ConvertNotValidCurrentPageToNotFoundListener->onKernelException(object(ExceptionEvent), 'kernel.exception', object(TraceableEventDispatcher)) (vendor/symfony/event-dispatcher/Debug/WrappedListener.php:115) at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(object(ExceptionEvent), 'kernel.exception', object(TraceableEventDispatcher)) (vendor/symfony/event-dispatcher/EventDispatcher.php:206) at Symfony\Component\EventDispatcher\EventDispatcher->callListeners(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'kernel.exception', object(ExceptionEvent)) (vendor/symfony/event-dispatcher/EventDispatcher.php:56) at Symfony\Component\EventDispatcher\EventDispatcher->dispatch(object(ExceptionEvent), 'kernel.exception') (vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:127) at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch(object(ExceptionEvent), 'kernel.exception') (vendor/symfony/http-kernel/HttpKernel.php:221) at Symfony\Component\HttpKernel\HttpKernel->handleThrowable(object(OutOfRangeCurrentPageException), object(Request), 1) (vendor/symfony/http-kernel/HttpKernel.php:89) at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true) (vendor/symfony/http-kernel/Kernel.php:184) at Symfony\Component\HttpKernel\Kernel->handle(object(Request)) (vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php:35) at Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run() (vendor/autoload_runtime.php:29) at require_once('/www/htdocs/w0174c87/www/findevegan.de/vendor/autoload_runtime.php') (public/index.php:5) |
[1/2]
OutOfRangeCurrentPageException
|
---|
Pagerfanta\Exception\OutOfRangeCurrentPageException: Page "6" does not exist. The currentPage must be inferior to "4" at vendor/pagerfanta/core/Pagerfanta.php:216 at Pagerfanta\Pagerfanta->normalizeOutOfRangeCurrentPage(6) (vendor/pagerfanta/core/Pagerfanta.php:189) at Pagerfanta\Pagerfanta->filterOutOfRangeCurrentPage(6) (vendor/pagerfanta/core/Pagerfanta.php:170) at Pagerfanta\Pagerfanta->filterCurrentPage(6) (vendor/pagerfanta/core/Pagerfanta.php:157) at Pagerfanta\Pagerfanta->setCurrentPage(6) (src/Repository/RecipeRepository.php:38) at App\Repository\RecipeRepository->getPaginator(object(QueryBuilder), '6') (src/Repository/RecipeRepository.php:142) at App\Repository\RecipeRepository->findRecipeListForCriterias('6', null, 'smarticular', null) (src/Controller/RecipeController.php:159) at App\Controller\RecipeController->blog(object(Request), 'smarticular', null, null) (vendor/symfony/http-kernel/HttpKernel.php:163) at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1) (vendor/symfony/http-kernel/HttpKernel.php:74) at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true) (vendor/symfony/http-kernel/Kernel.php:184) at Symfony\Component\HttpKernel\Kernel->handle(object(Request)) (vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php:35) at Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run() (vendor/autoload_runtime.php:29) at require_once('/www/htdocs/w0174c87/www/findevegan.de/vendor/autoload_runtime.php') (public/index.php:5) |