/** * Update entry by id * @param int $id * @param array $timeSet * @param int $articleId * @param string $fieldName * @param string $recurring */ public function update($id, $timeSet, $articleId = null, $fieldName = null, $recurring = null, $otherInfo = null) { $em = $this->getEntityManager(); $entry = $this->find($id); if (!$entry) { return false; } if (is_null($articleId)) { $articleId = $entry->getArticleId(); } if (is_null($fieldName)) { $fieldName = $entry->getFieldName(); } $insertValues = $this->buildInsertValues($timeSet, $recurring); try { $em->getConnection()->beginTransaction(); $em->remove($entry); foreach ($insertValues as $dateValue) { foreach (array_merge(array($dateValue), $dateValue->getSpawns()) as $dateValue) { $articleDatetime = new ArticleDatetime(); $articleDatetime->setValues($dateValue, $articleId, $fieldName, $entry->getArticleType(), $otherInfo); $em->persist($articleDatetime); } } $em->flush(); $em->getConnection()->commit(); } catch (\Exception $e) { $em->getConnection()->rollback(); $em->close(); return $e; } }
public function setValues($dateData, $article, $fieldName, $articleType = NULL, $otherInfo = NULL) { $this->__load(); return parent::setValues($dateData, $article, $fieldName, $articleType, $otherInfo); }