Exemplo n.º 1
0
 /**
  * @param UpdateWorkshop $command
  * @throws Exception
  */
 public function handle(UpdateWorkshop $command)
 {
     /** @var Workshop $workshop */
     $workshop = $this->workshopRepository->findOneById($command->id);
     $workshop->updateWithCommand($command);
     $workshop->updateSlug($this->slugGenerator->generate($workshop));
     $command->lessons;
     foreach ($workshop->getLessons() as $existingLesson) {
         if (!in_array($existingLesson, $command->lessons)) {
             $this->lessonRepository->remove($existingLesson);
             $workshop->getLessons()->removeElement($existingLesson);
         }
     }
     $this->workshopRepository->update($workshop);
 }