public function add(QuestionSheet $sheet)
 {
     if (NULLUser::getInstance() === $sheet->getOwner()) {
         throw new \InvalidArgumentException("incorrect user");
     }
     $this->entityManager->persist($sheet);
     $this->entityManager->flush();
 }
 /**
  * Sets the current user as the owner.
  * 
  * @param array $arr with keys "content", "name"
  * 
  * @throws InvalidArgumentException
  * @return QuestionSheet
  */
 public function buildFromArray(array $arr)
 {
     if (!empty(array_diff(["content", "name"], array_keys($arr)))) {
         throw new InvalidArgumentException("Incorrect input array");
     }
     $sheet = new QuestionSheet();
     $sheet->setContent($arr["content"]);
     $sheet->setName($arr["name"]);
     $sheet->setOwner($this->currentUser);
     return $sheet;
 }
 public function oneSheetToArray(QuestionSheet $sheet)
 {
     return ['name' => $sheet->getName(), 'content' => $sheet->getContent()];
 }
 protected function check_delete(QuestionSheet $sheet, User $user)
 {
     return $user->isTheSameAs($sheet->getOwner());
 }
 /**
  * Changes values of this object.
  * 
  * @param QuestionSheet $anotherSheet
  * 
  * @return null
  */
 public function copyDataFrom(QuestionSheet $anotherSheet)
 {
     $this->setContent($anotherSheet->getContent());
     $this->setName($anotherSheet->getName());
 }