ProjectMenuCommand::handle()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 0
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Thinktomorrow\Chief\App\Console;
4
5
use Thinktomorrow\Chief\Site\Menu\Application\ProjectModelData;
6
use Thinktomorrow\Chief\Site\Menu\MenuItem;
7
8
class ProjectMenuCommand extends BaseCommand
9
{
10
    protected $signature = 'chief:project-menu';
11
    protected $description = 'Update all menu items with the current model data.';
12
    private ProjectModelData $projectModelData;
13
14
    public function __construct(ProjectModelData $projectModelData)
15
    {
16
        parent::__construct();
17
18
        $this->projectModelData = $projectModelData;
19
    }
20
21
    public function handle(): void
22
    {
23
        $menuItems = MenuItem::all();
24
25
        $this->info(count($menuItems) . ' menuitems will be updated.');
26
27
        foreach ($menuItems as $menuItem) {
28
            $this->projectModelData->handleByMenuItem($menuItem);
29
        }
30
31
        $this->info(' All menuitems updated.');
32
    }
33
}
34