Conditions | 3 |
Paths | 2 |
Total Lines | 34 |
Code Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
33 | public function __invoke(ChangeParentMenuItemCommand $command) |
||
34 | { |
||
35 | $menu = $this->repository->menuOfId( |
||
36 | MenuId::generate( |
||
37 | $command->menuId() |
||
38 | ) |
||
39 | ); |
||
40 | if (!$menu instanceof Menu) { |
||
41 | throw new MenuDoesNotExistException(); |
||
42 | } |
||
43 | $translation = $menu->{$command->locale()}(); |
||
44 | |||
45 | $menuItemParent = $translation->item( |
||
46 | null !== $command->menuItemParentId() |
||
47 | ? MenuItemId::generate($command->menuItemParentId()) |
||
48 | : null |
||
49 | ); |
||
50 | |||
51 | $translation->item( |
||
52 | MenuItemId::generate( |
||
53 | $command->menuItemId() |
||
54 | ) |
||
55 | )->changeParent( |
||
56 | $menuItemParent->id() |
||
57 | ); |
||
58 | |||
59 | $menu->removeTranslation( |
||
60 | new Locale( |
||
61 | $command->locale() |
||
62 | ) |
||
63 | ); |
||
64 | $menu->addTranslation($translation); |
||
65 | $this->repository->persist($menu); |
||
66 | } |
||
67 | } |
||
68 |