Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $slot_id = $input->getArgument('slot_id');
     $helper = $this->getHelper('question');
     $question = new ConfirmationQuestion('Are you sure?', false);
     $confirm = NULL;
     if (($slot = $this->repository->slot($slot_id)) && ($confirm = $helper->ask($input, $output, $question)) && $this->repository->delete($slot_id)) {
         $deleted = $this->connector->ticketDetails($slot->tid);
         $output->writeln(sprintf('Deleted slot <comment>%d</comment> against ticket <info>%d</info>: %s, duration <info>%s</info>', $slot->id, $slot->tid, $deleted->getTitle(), Formatter::formatDuration($slot->end - $slot->start)));
         return;
     }
     if ($confirm !== FALSE) {
         $output->writeln('<error>Cannot delete slot, either does not exist or has been sent to back end.</error>');
     }
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $slot1 = $input->getArgument('slot1');
     $slot2 = $input->getArgument('slot2');
     list($entry1, $entry2) = $this->validateSlots($slot1, $slot2, $output);
     // Create a new combined entry and then remove fields we don't want to keep
     // around in the new entry.
     $combined_entry = clone $entry1;
     unset($combined_entry->id, $combined_entry->category, $combined_entry->comment, $combined_entry->teid);
     // Extend the entry date by the amount of time logged in the second entry.
     $combined_entry->end = $entry1->end + ($entry2->end - $entry2->start);
     // Insert the new entry, if all is well delete the two existing ones.
     if ($new_slot = $this->repository->insert((array) $combined_entry)) {
         $this->repository->delete($entry1->id);
         $this->repository->delete($entry2->id);
         $output->writeln(sprintf('Combined %s and %s into new slot %s', $slot1, $slot2, $new_slot));
     }
 }