| Conditions | 2 |
| Paths | 2 |
| Total Lines | 24 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 33 | public function __invoke(RemoveMenuItemCommand $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 | $locale = new Locale( |
||
| 44 | $command->locale() |
||
| 45 | ); |
||
| 46 | $translation = $menu->{$command->locale()}(); |
||
| 47 | |||
| 48 | $translation->removeItem( |
||
| 49 | MenuItemId::generate( |
||
| 50 | $command->menuItemId() |
||
| 51 | ) |
||
| 52 | ); |
||
| 53 | $menu->removeTranslation($locale); |
||
| 54 | $menu->addTranslation($translation); |
||
| 55 | $this->repository->persist($menu); |
||
| 56 | } |
||
| 57 | } |
||
| 58 |