1 | <?php |
||||||||
2 | |||||||||
3 | namespace PTS\SyliusReferralPlugin\Menu; |
||||||||
4 | |||||||||
5 | use Knp\Menu\FactoryInterface; |
||||||||
6 | use Knp\Menu\ItemInterface; |
||||||||
7 | use Sylius\Bundle\UiBundle\Menu\Event\MenuBuilderEvent; |
||||||||
8 | use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
||||||||
9 | |||||||||
10 | final class DistributorAccountMenuBuilder |
||||||||
11 | { |
||||||||
12 | public const EVENT_NAME = 'sylius.menu.shop.account'; |
||||||||
13 | |||||||||
14 | /** |
||||||||
15 | * @var FactoryInterface |
||||||||
16 | */ |
||||||||
17 | private $factory; |
||||||||
18 | |||||||||
19 | /** |
||||||||
20 | * @var EventDispatcherInterface |
||||||||
21 | */ |
||||||||
22 | private $eventDispatcher; |
||||||||
23 | |||||||||
24 | /** |
||||||||
25 | * @param FactoryInterface $factory |
||||||||
26 | * @param EventDispatcherInterface $eventDispatcher |
||||||||
27 | */ |
||||||||
28 | public function __construct(FactoryInterface $factory, EventDispatcherInterface $eventDispatcher) |
||||||||
29 | { |
||||||||
30 | $this->factory = $factory; |
||||||||
31 | $this->eventDispatcher = $eventDispatcher; |
||||||||
32 | } |
||||||||
33 | |||||||||
34 | /** |
||||||||
35 | * @param array $options |
||||||||
36 | * |
||||||||
37 | * @return ItemInterface |
||||||||
38 | */ |
||||||||
39 | public function createMenu(array $options): ItemInterface |
||||||||
0 ignored issues
–
show
|
|||||||||
40 | { |
||||||||
41 | $menu = $this->factory->createItem('root'); |
||||||||
42 | $menu->setLabel('sylius.menu.shop.account.header'); |
||||||||
43 | |||||||||
44 | $menu |
||||||||
45 | ->addChild('dashboard', ['route' => 'sylius_shop_account_dashboard']) |
||||||||
46 | ->setLabel('sylius.menu.shop.account.dashboard') |
||||||||
47 | ->setLabelAttribute('icon', 'home') |
||||||||
48 | ; |
||||||||
49 | $menu |
||||||||
50 | ->addChild('personal_information', ['route' => 'sylius_shop_account_profile_update']) |
||||||||
51 | ->setLabel('sylius.menu.shop.account.personal_information') |
||||||||
52 | ->setLabelAttribute('icon', 'user') |
||||||||
53 | ; |
||||||||
54 | $menu |
||||||||
55 | ->addChild('change_password', ['route' => 'sylius_shop_account_change_password']) |
||||||||
56 | ->setLabel('sylius.menu.shop.account.change_password') |
||||||||
57 | ->setLabelAttribute('icon', 'lock') |
||||||||
58 | ; |
||||||||
59 | $menu |
||||||||
60 | ->addChild('address_book', ['route' => 'sylius_shop_account_address_book_index']) |
||||||||
61 | ->setLabel('sylius.menu.shop.account.address_book') |
||||||||
62 | ->setLabelAttribute('icon', 'book') |
||||||||
63 | ; |
||||||||
64 | $menu |
||||||||
65 | ->addChild('order_history', ['route' => 'sylius_shop_account_order_index']) |
||||||||
66 | ->setLabel('sylius.menu.shop.account.order_history') |
||||||||
67 | ->setLabelAttribute('icon', 'cart') |
||||||||
68 | ; |
||||||||
69 | $menu |
||||||||
70 | ->addChild('customers', ['route' => 'app_account_customers']) |
||||||||
71 | ->setLabel('app.menu.shop.account.customers') |
||||||||
72 | ->setLabelAttribute('icon', 'star') |
||||||||
73 | ; |
||||||||
74 | |||||||||
75 | $this->eventDispatcher->dispatch(self::EVENT_NAME, new MenuBuilderEvent($this->factory, $menu)); |
||||||||
0 ignored issues
–
show
The call to
Symfony\Contracts\EventD...erInterface::dispatch() has too many arguments starting with new Sylius\Bundle\UiBund...($this->factory, $menu) .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above. ![]() self::EVENT_NAME of type string is incompatible with the type object expected by parameter $event of Symfony\Contracts\EventD...erInterface::dispatch() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
76 | |||||||||
77 | return $menu; |
||||||||
78 | } |
||||||||
79 | } |
||||||||
80 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.