/** * Move under a new parent * * @param sfAssetFolder $new_parent */ public function move(sfAssetFolder $new_parent) { // controls if ($this->isRoot()) { throw new sfAssetException('The root folder cannot be moved'); } else { if ($new_parent->hasSubFolder($this->getName())) { throw new sfAssetException('The target folder "%folder%" already contains a folder named "%name%". The folder has not been moved.', array('%folder%' => $new_parent, '%name%' => $this->getName())); } else { if ($new_parent->isDescendantOf($this)) { throw new sfAssetException('The target folder cannot be a subfolder of moved folder. The folder has not been moved.'); } else { if ($this->retrieveParent() !== $new_parent->getId()) { $descendants = $this->getDescendants(); $old_path = $this->getFullPath(); $this->moveToLastChildOf($new_parent); // Update relative path $this->save(); // move its assets self::movePhysically($old_path, $this->getFullPath()); foreach ($descendants as $descendant) { // Update relative path $descendant->save(); } } } } } // else: nothing to do }