/**
  * @param Book $book
  * @return Book
  */
 public function clearAuthors(Book $book)
 {
     $book->clearAuthors();
     $this->em->persist($book);
     $this->em->flush();
     return $book;
 }
Exemple #2
0
 /**
  * @param $data
  * @param $book
  * @return void
  * @throws NotFoundException
  */
 private function syncAuthors($data, Book $book)
 {
     $book->clearAuthors();
     if (isset($data['authors'])) {
         foreach ($data['authors'] as $author) {
             $auth = $this->findOrCreateAuthor($author);
             $book->addAuthor($auth);
         }
     }
 }