/** * Move under a new parent * * @param sfAssetFolder $new_parent */ public function move(sfAssetFolder $new_parent) { // controls if ($this->getNode()->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->getNode()->isDescendantOf($this)) { throw new sfAssetException('The target folder cannot be a subfolder of moved folder. The folder has not been moved.'); } else { if ($this->getId() == $new_parent->getId()) { return; } } } } $old_path = $this->getFullPath(); $this->getNode()->moveAsLastChildOf($new_parent); $this->save(); $descendants = $this->getNode()->getChildren(); $descendants = $descendants ? $descendants : array(); // move its assets self::movePhysically($old_path, $this->getFullPath()); foreach ($descendants as $descendant) { // Update relative path $descendant->save(); } // else: nothing to do }