Esempio n. 1
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));
     }
 }