protected function execute(InputInterface $input, OutputInterface $output) { try { $id = (int) $input->getArgument('unidade'); if ($id > 0) { // verificando unidade $unidade = $this->em->find('Novosga\\Model\\Unidade', $id); if (!$unidade) { throw new Exception("Unidade inválida: {$id}"); } } $service = new AtendimentoService($this->em); $service->acumularAtendimentos($id); $output->writeln('<info>Senhas reiniciadas com sucesso</info>'); } catch (Exception $e) { $output->writeln("<error>{$e->getMessage()}</error>"); } }
public function acumular_atendimentos(Context $context) { $response = new JsonResponse(); try { if (!$context->request()->isPost()) { throw new Exception(_('Somente via POST')); } $service = new AtendimentoService($this->em()); $service->acumularAtendimentos(); $response->success = true; } catch (\Exception $e) { $response->message = $e->getMessage(); } return $response; }