entityManager = $container->get('doctrine')->getManager(); } protected function configure(): void { $this->setDescription(self::$defaultDescription) ->addArgument('onlineMode', InputArgument::OPTIONAL, 'onlineMode [0,1]') ; } protected function execute(InputInterface $input, OutputInterface $output): int { $this->io = new SymfonyStyle($input, $output); $infoclinica = new Rest(); $onlineMode = $input->getArgument('onlineMode'); foreach ($this->entityManager->getRepository(Department::class)->findAll() as $department) { foreach ($infoclinica->getSpecialists($department->getDid(), $onlineMode)['response']['data'] as $doctor) { $iDoctor = $this->entityManager->getRepository(Idoctor::class) ->findOneBy([ 'dcode' => $doctor['dcode'], 'departmentId' => $doctor['departmentId'], 'onlineMode' => $onlineMode ]); if (! $iDoctor) { $this->io->success('create in specialist '. $doctor['dcode']); $iDoctor = new Idoctor(); } else { $this->io->success('upgrade in specialist '. $doctor['dcode']); } $iDoctor ->setDcode($doctor['dcode']) ->setName($doctor['name']) ->setDepartmentId($doctor['departmentId']) ->setDepartmentName($doctor['departmentName']) ->setFilialId($doctor['filialId']) ->setFilialName($doctor['filialName']) ->setComment(empty($doctor['comment'])? '':$doctor['comment']) ->setNearestDate($doctor['nearestDate']) ->setViewInWeb($doctor['viewInWeb']) ->setOnlineMode($onlineMode) ; $this->entityManager->persist($iDoctor); } $this->entityManager->flush(); } return Command::SUCCESS; } }