public function digipolisSwitchPrevious($releasesDir, $currentSymlink)
    {
        $finder = new Finder();
        // Get all releases.
        $releases = iterator_to_array(
            $finder
                ->directories()
                ->in($releasesDir)
                ->sortByName()
                ->depth(0)
                ->getIterator()
        );
        // Last element is the current release.
        array_pop($releases);
        if ($releases) {
            // Normalize the paths.
            $currentDir = readlink($currentSymlink);
            $releasesDir = realpath($releasesDir);
            // Get the right folder within the release dir to symlink.
            $relativeRootDir = substr($currentDir, strlen($releasesDir . '/'));
            $parts = explode('/', $relativeRootDir);
            array_shift($parts);
            $relativeWebDir = implode('/', $parts);
            $previous = end($releases)->getRealPath() . '/' . $relativeWebDir;
            return $this->taskExec('ln -s -T -f ' . $previous . ' ' . $currentSymlink)
                ->run();
        }
    }
public function digipolisSwitchPrevious($releasesDir, $currentSymlink)
    {
        $finder = new Finder();
        // Get all releases.
        $releases = iterator_to_array(
            $finder
                ->directories()
                ->in($releasesDir)
                ->sortByName()
                ->depth(0)
                ->getIterator()
        );
        // Last element is the current release.
        array_pop($releases);
        if ($releases) {
            // Normalize the paths.
            $currentDir = readlink($currentSymlink);
            $releasesDir = realpath($releasesDir);
            // Get the right folder within the release dir to symlink.
            $relativeRootDir = substr($currentDir, strlen($releasesDir . '/'));
            $parts = explode('/', $relativeRootDir);
            array_shift($parts);
            $relativeWebDir = implode('/', $parts);
            $previous = end($releases)->getRealPath() . '/' . $relativeWebDir;
            return $this->taskExec('ln -s -T -f ' . $previous . ' ' . $currentSymlink)
                ->run();
        }
    }
public function digipolisSwitchPrevious ( $ releasesDir , $ currentSymlink ) { $ finder = new Finder ( ) ; // Get all releases. $ releases = iterator_to_array ( $ finder -> directories ( ) -> in ( $ releasesDir ) -> sortByName ( ) -> depth ( 0 ) -> getIterator ( ) ) ; // Last element is the current release. array_pop ( $ releases ) ; if ( $ releases ) { // Normalize the paths. $ currentDir = readlink ( $ currentSymlink ) ; $ releasesDir = realpath ( $ releasesDir ) ; // Get the right folder within the release dir to symlink. $ relativeRootDir = substr ( $ currentDir , strlen ( $ releasesDir . '/' ) ) ; $ parts = explode ( '/' , $ relativeRootDir ) ; array_shift ( $ parts ) ; $ relativeWebDir = implode ( '/' , $ parts ) ; $ previous = end ( $ releases ) -> getRealPath ( ) . '/' . $ relativeWebDir ; return $ this -> taskExec ( 'ln -s -T -f ' . $ previous . ' ' . $ currentSymlink ) -> run ( ) ; } }
Switch the current release symlink to the previous release.

@param string $releasesDir
Path to the folder containing all releases.
@param string $currentSymlink
Path to the current release symlink.
Switch the current release symlink to the previous release .