/**
  * Removes this object and all descendants from datastore.
  *
  * @param      PropelPDO Connection to use.
  * @return     void
  * @throws     PropelException
  */
 public function delete(PropelPDO $con = null)
 {
     // delete node first
     parent::delete($con);
     // delete descendants and then shift tree
     sfAssetFolderPeer::deleteDescendants($this, $con);
 }
Ejemplo n.º 2
0
 public function getPeer()
 {
     if (self::$peer === null) {
         self::$peer = new sfAssetFolderPeer();
     }
     return self::$peer;
 }
 /**
  * Also delete all contents
  *
  * @param Connection $con
  * @param Boolean $force If true, do not throw an exception if the physical directories cannot be removed
  */
 public function delete(Doctrine_connection $con = null, $force = false)
 {
     $success = true;
     $descendants = $this->getNode()->getDescendants();
     if ($descendants !== false) {
         foreach ($descendants as $descendant) {
             $success = $descendant->delete($con, $force) && $success;
         }
     }
     foreach ($this->getAssets() as $asset) {
         $success = $asset->delete() && $success;
     }
     // Remove thumbnail subdir
     $success = rmdir(sfAssetsLibraryTools::getThumbnailDir($this->getFullPath())) && $success;
     // Remove dir itself
     $success = rmdir($this->getFullPath()) && $success;
     if ($success || $force) {
         parent::delete($con);
     } else {
         throw new sfAssetException('Impossible to delete folder "%name%"', array('%name%' => $this->getName()));
     }
     return $success;
 }
 public function save(Doctrine_Connection $conn = null)
 {
     $exists = $this->exists();
     parent::save($conn);
     if (!is_null($this->old_path) && $exists) {
         $this->rename();
         $this->old_path = null;
     }
 }
Ejemplo n.º 5
0
 public function save($con = null)
 {
     if (!$this->isColumnModified(sfAssetFolderPeer::RELATIVE_PATH)) {
         if ($this->getParent()) {
             $this->setRelativePath($this->getParent()->getRelativePath() . '/' . $this->getName());
         } else {
             $this->setRelativePath($this->getName());
         }
     }
     // physical existence
     if (!$this->exists()) {
         if (!$this->create()) {
             throw new sfAssetException('Impossible to create folder "%name%"', array('%name%' => $this->getRelativePath()));
         }
     }
     return parent::save($con);
 }