em = $em; $this->repo = $repo; } protected function configure() { $this ->setDescription('Unpublish a mailing') ->addArgument('id', InputArgument::OPTIONAL, 'ID of the mailing') ; } protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); $id = $input->getArgument('id'); $entity = $this->repo->find(['id' => $id]); if (null === $entity) { $io->error(sprintf('"%s" is not found!', $id)); return Command::FAILURE; } $entity->setIsPublic(false); $this->em->persist($entity); $this->em->flush(); $io->success(sprintf('"%s" is now private', $entity->getId())); return Command::SUCCESS; } }