Example #1
0
 /**
  * @param $categoryId
  * @param $title
  * @param $text
  * @param $startDate
  * @param $endDate
  * @param $mapAddress
  *
  * @return int
  * @throws \RcmEventCalenderCore\Exception\InvalidArgumentException
  */
 function createEvent($categoryId, $title, $text, $startDate, $endDate, $mapAddress)
 {
     $category = $this->categoryRepo->findOneByCategoryId($categoryId);
     if (!$category) {
         throw new InvalidArgumentException("Category #{$categoryId} not found");
     }
     $event = new Event();
     $event->setCategory($category);
     $event->setTitle($title);
     $event->setText($text);
     $event->setMapAddress($mapAddress);
     $event->setStartDateFromString($startDate);
     $event->setEndDateFromString($endDate);
     $this->entityMgr->persist($event);
     $this->entityMgr->flush();
     return $event->getEventId();
 }