/** * Remove the translation for a given locale * * @param string $locale Locale to use for the translation, e.g. 'fr_FR' * @param PropelPDO $con an optional connection object * * @return Help The current object (for fluent API support) */ public function removeTranslation($locale = 'en_US', PropelPDO $con = null) { if (!$this->isNew()) { HelpI18nQuery::create()->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))->delete($con); } if (isset($this->currentTranslations[$locale])) { unset($this->currentTranslations[$locale]); } foreach ($this->collHelpI18ns as $key => $translation) { if ($translation->getLocale() == $locale) { unset($this->collHelpI18ns[$key]); break; } } return $this; }
/** * Removes this object from datastore and sets delete attribute. * * @param PropelPDO $con * @return void * @throws PropelException * @throws Exception * @see BaseObject::setDeleted() * @see BaseObject::isDeleted() */ public function delete(PropelPDO $con = null) { if ($this->isDeleted()) { throw new PropelException("This object has already been deleted."); } if ($con === null) { $con = Propel::getConnection(HelpI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { EventDispatcherProxy::trigger(array('delete.pre', 'model.delete.pre'), new ModelEvent($this)); $deleteQuery = HelpI18nQuery::create()->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { $deleteQuery->delete($con); $this->postDelete($con); // event behavior EventDispatcherProxy::trigger(array('delete.post', 'model.delete.post'), new ModelEvent($this)); $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (Exception $e) { $con->rollBack(); throw $e; } }