コード例 #1
0
ファイル: BasePrincipal.php プロジェクト: peterAK/pgs-sts
 /**
  * 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    Principal The current object (for fluent API support)
  */
 public function removeTranslation($locale = 'en_US', PropelPDO $con = null)
 {
     if (!$this->isNew()) {
         PrincipalI18nQuery::create()->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))->delete($con);
     }
     if (isset($this->currentTranslations[$locale])) {
         unset($this->currentTranslations[$locale]);
     }
     foreach ($this->collPrincipalI18ns as $key => $translation) {
         if ($translation->getLocale() == $locale) {
             unset($this->collPrincipalI18ns[$key]);
             break;
         }
     }
     return $this;
 }
コード例 #2
0
ファイル: BasePrincipalI18n.php プロジェクト: peterAK/pgs-sts
 /**
  * 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(PrincipalI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         EventDispatcherProxy::trigger(array('delete.pre', 'model.delete.pre'), new ModelEvent($this));
         $deleteQuery = PrincipalI18nQuery::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;
     }
 }