seasonRepository->findOneBy(['seasonCode' => $seasonCode]); if (null === $season) { throw new \InvalidArgumentException('Season not found'); } $user = $this->userRepository->findOneBy(['email' => $email]); if (null === $user) { throw new \InvalidArgumentException('User not found'); } $season->addOwner($user); $this->entityManager->flush(); } catch (\InvalidArgumentException $invalidArgumentException) { $io->error($invalidArgumentException->getMessage()); return Command::FAILURE; } return Command::SUCCESS; } }