| Conditions | 3 |
| Paths | 3 |
| Total Lines | 29 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 35 | public function __invoke(AddMenuCommand $command) |
||
| 36 | { |
||
| 37 | if (null !== $menuId = $command->menuId()) { |
||
| 38 | $menu = $this->repository->menuOfId( |
||
| 39 | MenuId::generate( |
||
| 40 | $menuId |
||
| 41 | ) |
||
| 42 | ); |
||
| 43 | if ($menu instanceof Menu) { |
||
| 44 | throw new MenuIsAlreadyExistsException(); |
||
| 45 | } |
||
| 46 | } |
||
| 47 | |||
| 48 | $menu = new Menu( |
||
| 49 | MenuId::generate( |
||
| 50 | $command->menuId() |
||
| 51 | ), |
||
| 52 | new MenuTranslation( |
||
| 53 | MenuTranslationId::generate(), |
||
| 54 | new Locale( |
||
| 55 | $command->locale() |
||
| 56 | ), |
||
| 57 | new MenuName( |
||
| 58 | $command->name() |
||
| 59 | ) |
||
| 60 | ) |
||
| 61 | ); |
||
| 62 | $this->repository->persist($menu); |
||
| 63 | } |
||
| 64 | } |
||
| 65 |