Trying to setup PrestaSitemapBundle, but when I try to add listener an error happens.
Catchable Fatal Error: Argument 1 passed to AppBundle\EventListener\SitemapListener::__construct() must implement interface Symfony\Component\Routing\RouterInterface, array given, called in /var/www/websitename/var/cache/dev/appDevDebugProjectContainer.php on line 3268 and defined" at n/a in /var/www/websitename/src/AppBundle/EventListener/SitemapListener.php line 28
services.yml
services:
sitemap.listener:
class: AppBundle\EventListener\SitemapListener
arguments:
- ["@router"]
tags: [{name: "presta.sitemap.listener"}]
Moreover PhpStorm shows that "multiple definition of class Routerinterface".
Is it connected with error somehow?
There is an error in your service definition.
Both..
array:
- 1
- 2
..and..
array: [1, 2]
..are ways to define a named array.
Your service definition...
arguments:
- ['@router']
.. is essentially creating an array with the first value being an array with '@router' as the first value of the internal array. To fix this you need to pick one of the ways to define your array. So either..
arguments:
- '@router'
.. or ..
arguments: ['@router']