commands; /** @var Command $command */ foreach ($commands as $command) { $commandGroup->addCommand($command->getEntity()); } $this->entityManager->persist($commandGroup); $this->entityManager->flush(); return new JsonResponse(data: 'Commands added to command group successfully', status: Response::HTTP_OK); } }