public function setFilename($filename)
    {
        $filename = $this->filterFilename($filename);

        // Check existing folder path
        $folder = '';
        $parent = $this->Parent();
        if ($parent && $parent->exists()) {
            $folder = $parent->getFilename();
        }

        // Detect change in foldername
        $newFolder = ltrim(dirname(trim($filename, '/')), '.');
        if ($folder !== $newFolder) {
            if (!$newFolder) {
                $this->ParentID = 0;
            } else {
                $parent = Folder::find_or_make($newFolder);
                $this->ParentID = $parent->ID;
            }
        }

        // Update base name
        $this->Name = basename($filename);
        return $this;
    }
public function setFilename($filename)
    {
        $filename = $this->filterFilename($filename);

        // Check existing folder path
        $folder = '';
        $parent = $this->Parent();
        if ($parent && $parent->exists()) {
            $folder = $parent->getFilename();
        }

        // Detect change in foldername
        $newFolder = ltrim(dirname(trim($filename, '/')), '.');
        if ($folder !== $newFolder) {
            if (!$newFolder) {
                $this->ParentID = 0;
            } else {
                $parent = Folder::find_or_make($newFolder);
                $this->ParentID = $parent->ID;
            }
        }

        // Update base name
        $this->Name = basename($filename);
        return $this;
    }
public function setFilename ( $ filename ) { $ filename = $ this -> filterFilename ( $ filename ) ; // Check existing folder path $ folder = '' ; $ parent = $ this -> Parent ( ) ; if ( $ parent && $ parent -> exists ( ) ) { $ folder = $ parent -> getFilename ( ) ; } // Detect change in foldername $ newFolder = ltrim ( dirname ( trim ( $ filename , '/' ) ) , '.' ) ; if ( $ folder !== $ newFolder ) { if ( ! $ newFolder ) { $ this -> ParentID = 0 ; } else { $ parent = Folder :: find_or_make ( $ newFolder ) ; $ this -> ParentID = $ parent -> ID ; } } // Update base name $ this -> Name = basename ( $ filename ) ; return $ this ; }
Update the ParentID and Name for the given filename.

On save, the underlying DBFile record will move the underlying file to this location.
Thus it will not update the underlying Filename value until this is done.

@param string $filename
@return $this
Update the ParentID and Name for the given filename .