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);
$em->getConnection()->beginTransaction();
try {
$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;
}
}