Manager/FileManager.php
protected function getFileRelativePath($filePath)
    {
        $commonParts = array();

        // replace window \ to work with /
        $rootDir = (false !== strpos($this->rootDir, '\\')) ? str_replace('\\', '/', $this->rootDir) : $this->rootDir;

        $antiSlash = false;
        if (false !== strpos($filePath, '\\')) {
            $filePath = str_replace('\\', '/', $filePath);
            $antiSlash = true;
        }

        $rootDirParts = explode('/', $rootDir);
        $filePathParts = explode('/', $filePath);

        $i = 0;
        while ($i < count($rootDirParts)) {
            if (isset($rootDirParts[$i], $filePathParts[$i]) && $rootDirParts[$i] == $filePathParts[$i]) {
                $commonParts[] = $rootDirParts[$i];
            }
            $i++;
        }

        $filePath = str_replace(implode('/', $commonParts).'/', '', $filePath);

        $nbCommonParts = count($commonParts);
        $nbRootParts = count($rootDirParts);

        for ($i = $nbCommonParts; $i < $nbRootParts; $i++) {
            $filePath = '../'.$filePath;
        }

        return $antiSlash ? str_replace('/', '\\', $filePath) : $filePath;
    }
protected function getFileRelativePath($filePath)
    {
        $commonParts = array();

        // replace window \ to work with /
        $rootDir = (false !== strpos($this->rootDir, '\\')) ? str_replace('\\', '/', $this->rootDir) : $this->rootDir;

        $antiSlash = false;
        if (false !== strpos($filePath, '\\')) {
            $filePath = str_replace('\\', '/', $filePath);
            $antiSlash = true;
        }

        $rootDirParts = explode('/', $rootDir);
        $filePathParts = explode('/', $filePath);

        $i = 0;
        while ($i < count($rootDirParts)) {
            if (isset($rootDirParts[$i], $filePathParts[$i]) && $rootDirParts[$i] == $filePathParts[$i]) {
                $commonParts[] = $rootDirParts[$i];
            }
            $i++;
        }

        $filePath = str_replace(implode('/', $commonParts).'/', '', $filePath);

        $nbCommonParts = count($commonParts);
        $nbRootParts = count($rootDirParts);

        for ($i = $nbCommonParts; $i < $nbRootParts; $i++) {
            $filePath = '../'.$filePath;
        }

        return $antiSlash ? str_replace('/', '\\', $filePath) : $filePath;
    }
protected function getFileRelativePath ( $ filePath ) { $ commonParts = array ( ) ; // replace window \ to work with / $ rootDir = ( false !== strpos ( $ this -> rootDir , '\\' ) ) ? str_replace ( '\\' , '/' , $ this -> rootDir ) : $ this -> rootDir ; $ antiSlash = false ; if ( false !== strpos ( $ filePath , '\\' ) ) { $ filePath = str_replace ( '\\' , '/' , $ filePath ) ; $ antiSlash = true ; } $ rootDirParts = explode ( '/' , $ rootDir ) ; $ filePathParts = explode ( '/' , $ filePath ) ; $ i = 0 ; while ( $ i < count ( $ rootDirParts ) ) { if ( isset ( $ rootDirParts [ $ i ] , $ filePathParts [ $ i ] ) && $ rootDirParts [ $ i ] == $ filePathParts [ $ i ] ) { $ commonParts [ ] = $ rootDirParts [ $ i ] ; } $ i ++ ; } $ filePath = str_replace ( implode ( '/' , $ commonParts ) . '/' , '' , $ filePath ) ; $ nbCommonParts = count ( $ commonParts ) ; $ nbRootParts = count ( $ rootDirParts ) ; for ( $ i = $ nbCommonParts ; $ i < $ nbRootParts ; $ i ++ ) { $ filePath = '../' . $ filePath ; } return $ antiSlash ? str_replace ( '/' , '\\' , $ filePath ) : $ filePath ; }
Returns the relative according to the kernel.root_dir value.

@param string $filePath
@return string
Returns the relative according to the kernel . root_dir value .