KnpLabs / KnpPaginatorBundle

SEO friendly Symfony paginator to sort and paginate
http://knplabs.com/en/blog/knp-paginator-reborn
MIT License
1.76k stars 341 forks source link

Cannot forward abstract method "Knp\Component\Pager\PaginatorInterface::paginate()". #807

Open kasali opened 5 days ago

kasali commented 5 days ago
Q A
knp_paginator 6.5.0
Symfony version 6.4.11
PHP version 8.3.6

Support Question

The pagination is empty and i'm getting this error in problem tab of the vs terminal [{ "resource": "projectroot/var/cache/dev/Container8ruiQDM/PaginatorProxy9cc2a8f.php", "owner": "_generated_diagnostic_collectionname#6", "severity": 8, "message": "';' expected.", "source": "php", "startLineNumber": 28, "startColumn": 15, "endLineNumber": 28, "endColumn": 15 }]. here is the result of bin/console debug:config knp_paginator:

Current configuration for extension with alias "knp_paginator"

knp_paginator:
    page_range: 5
    default_options:
        page_name: page
        sort_field_name: sort
        sort_direction_name: direction
        distinct: true
        filter_field_name: filterField
        filter_value_name: filterValue
        page_out_of_range: ignore
        default_limit: 10
    template:
        pagination: '@KnpPaginator/Pagination/twitter_bootstrap_v4_pagination.html.twig'
        sortable: '@KnpPaginator/Pagination/sortable_link.html.twig'
        filtration: '@KnpPaginator/Pagination/filtration.html.twig'
        rel_links: '@KnpPaginator/Pagination/rel_links.html.twig'
    page_limit: null
    convert_exception: false

controller :

$annonces = $paginator->paginate(
            $annonceRepository->findAnnonces($element, $element2),
             $request->query->getInt('page', 1),
            6
 );

what i'm missing here

garak commented 5 days ago

I would try to clear cache

kasali commented 5 days ago

I've tried that and deleted the cache directory and still have this issue @garak

garak commented 5 days ago

What is $paginator? Can you see the service in console debug:container?

kasali commented 5 days ago

$paginatoris an instance of the KnpPaginatorBundle's pagination service (PaginatorInterface) :

public fucntion(PaginatorInterface $paginator){
    ......
}

Result of console:container knp

[9 ] knp_paginator
  [10] Knp\Component\Pager\ArgumentAccess\RequestArgumentAccess
  [11] knp_paginator.subscriber.paginate
  [12] knp_paginator.subscriber.sortable
  [13] knp_paginator.subscriber.filtration
  [14] knp_paginator.subscriber.sliding_pagination
  [15] knp_paginator.helper.processor
  [16] knp_paginator.twig.extension.pagination
  [17] Knp\Bundle\PaginatorBundle\Twig\Extension\PaginationRuntime
garak commented 4 days ago

What's the content of PaginatorProxy9cc2a8f.php at the given line?

kasali commented 4 days ago

it's underlining the return and saying ; espected :

 public function paginate(mixed $target, int $page = 1, ?int $limit = null, array $options = []): \Knp\Component\Pager\Pagination\PaginationInterface
    {
        if (isset($this->lazyObjectState)) {
            return ($this->lazyObjectState->realInstance ??= ($this->lazyObjectState->initializer)())->paginate(...\func_get_args());
        }

        return throw new \BadMethodCallException('Cannot forward abstract method "Knp\Component\Pager\PaginatorInterface::paginate()".');
    }
garak commented 4 days ago

Do you see any syntax error here?

kasali commented 4 days ago

No but it's underlining the "return" and I see ; expected in the tab problem of vscode

On Fri, Sep 20, 2024, 10:37 Massimiliano Arione @.***> wrote:

Do you see any syntax error here?

— Reply to this email directly, view it on GitHub https://github.com/KnpLabs/KnpPaginatorBundle/issues/807#issuecomment-2363411037, or unsubscribe https://github.com/notifications/unsubscribe-auth/AI36Y5VIR2ZEUNMLUZGFE2DZXP3GNAVCNFSM6AAAAABOPXWFAOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNRTGQYTCMBTG4 . You are receiving this because you authored the thread.Message ID: @.***>