Pagekit\Finder\Controller\FinderController::renameAction PHP Method

renameAction() public method

public renameAction ( $oldname, $newname )
    public function renameAction($oldname, $newname)
    {
        if (!$this->isValidFilename($newname)) {
            return $this->error(__('Invalid file name.'));
        }
        if (!($source = $this->getPath($oldname)) or !($target = $this->getPath($newname))) {
            return $this->error(__('Invalid path.'));
        }
        if ('w' !== $this->getMode($source) || file_exists($target) || 'w' !== $this->getMode(dirname($target))) {
            throw new ForbiddenException(__('Permission denied.'));
        }
        if (!rename($source, $target)) {
            return $this->error(__('Unable to rename.'));
        }
        return $this->success(__('Renamed.'));
    }