name = $commandGroup->getName(); if ($commandGroup->getCommands()) { foreach ($commandGroup->getCommands() as $command) { $this->commands[] = new CommandOutput($command); } } $this->position = $commandGroup->getPosition(); $this->enabled = $commandGroup->isEnabled(); } public function createOrUpdateEntity(?CommandGroup $commandGroup = null): CommandGroup { if (!$commandGroup) { $commandGroup = new CommandGroup(); } $commandGroup->setName($this->name); foreach ($this->commands as $command) { $commandsToAdd[] = $command->getEntity(); } $commandGroup->setCommands( $commandsToAdd ?? [] ); $commandGroup->setPosition($this->position); return $commandGroup; } }