includes/phing/src/Tasks/DrushGenerateAliasTask.php
public function main()
    {
        // Check if all required data is present.
        $this->checkRequirements();

        if ($this->_drushDir == '/sites/all/drush') {
            $drushDir = $this->_siteRoot.$this->_drushDir;
        } else {
            $drushDir = $this->_drushDir;
        }

        $aliasesFile = $drushDir.'/aliases.drushrc.php';

        $aliases = array(
            'default' => array(
                'uri'  => $this->_siteUrl,
                'root' => $this->_siteRoot,
            ),
            'docker' => array(
                'uri'  => $this->_siteUrl,
                'root' => $this->_siteRoot,
            ),
        );

        if (empty($this->_aliasName)) {
            $sites = new Finder();
            $sites
                ->directories()
                ->depth('== 0')
                ->exclude('all')
                ->in($this->_siteRoot.'/sites');

            foreach ($sites as $site) {
                $aliases[$site->getBasename()] = array(
                   'uri'  => $this->_siteUrl,
                   'root' => $aliases['default']['root'],
                );
            }
        } else {
            $aliases += $this->loadAliases($aliasesFile);
            $aliases[$this->_aliasName] = array(
                'uri'  => $this->_siteUrl,
                'root' => $aliases['default']['root'],
            );
        }//end if

        $aliasesArray = "<?php \n\n\$aliases = ".var_export($aliases, true).";";

        if (file_put_contents($aliasesFile, $aliasesArray)) {
            $this->log(
                "Succesfully wrote aliases to file '".$aliasesFile."'",
                Project::MSG_INFO
            );
        } else {
            $this->log(
                "Was unable to write aliases to file '".$aliasesFile."'",
                Project::MSG_WARN
            );
        }
    }
public function main()
    {
        // Check if all required data is present.
        $this->checkRequirements();

        if ($this->_drushDir == '/sites/all/drush') {
            $drushDir = $this->_siteRoot.$this->_drushDir;
        } else {
            $drushDir = $this->_drushDir;
        }

        $aliasesFile = $drushDir.'/aliases.drushrc.php';

        $aliases = array(
            'default' => array(
                'uri'  => $this->_siteUrl,
                'root' => $this->_siteRoot,
            ),
            'docker' => array(
                'uri'  => $this->_siteUrl,
                'root' => $this->_siteRoot,
            ),
        );

        if (empty($this->_aliasName)) {
            $sites = new Finder();
            $sites
                ->directories()
                ->depth('== 0')
                ->exclude('all')
                ->in($this->_siteRoot.'/sites');

            foreach ($sites as $site) {
                $aliases[$site->getBasename()] = array(
                   'uri'  => $this->_siteUrl,
                   'root' => $aliases['default']['root'],
                );
            }
        } else {
            $aliases += $this->loadAliases($aliasesFile);
            $aliases[$this->_aliasName] = array(
                'uri'  => $this->_siteUrl,
                'root' => $aliases['default']['root'],
            );
        }//end if

        $aliasesArray = "<?php \n\n\$aliases = ".var_export($aliases, true).";";

        if (file_put_contents($aliasesFile, $aliasesArray)) {
            $this->log(
                "Succesfully wrote aliases to file '".$aliasesFile."'",
                Project::MSG_INFO
            );
        } else {
            $this->log(
                "Was unable to write aliases to file '".$aliasesFile."'",
                Project::MSG_WARN
            );
        }
    }
public function main ( ) { // Check if all required data is present. $ this -> checkRequirements ( ) ; if ( $ this -> _drushDir == '/sites/all/drush' ) { $ drushDir = $ this -> _siteRoot . $ this -> _drushDir ; } else { $ drushDir = $ this -> _drushDir ; } $ aliasesFile = $ drushDir . '/aliases.drushrc.php' ; $ aliases = array ( 'default' => array ( 'uri' => $ this -> _siteUrl , 'root' => $ this -> _siteRoot , ) , 'docker' => array ( 'uri' => $ this -> _siteUrl , 'root' => $ this -> _siteRoot , ) , ) ; if ( empty ( $ this -> _aliasName ) ) { $ sites = new Finder ( ) ; $ sites -> directories ( ) -> depth ( '== 0' ) -> exclude ( 'all' ) -> in ( $ this -> _siteRoot . '/sites' ) ; foreach ( $ sites as $ site ) { $ aliases [ $ site -> getBasename ( ) ] = array ( 'uri' => $ this -> _siteUrl , 'root' => $ aliases [ 'default' ] [ 'root' ] , ) ; } } else { $ aliases += $ this -> loadAliases ( $ aliasesFile ) ; $ aliases [ $ this -> _aliasName ] = array ( 'uri' => $ this -> _siteUrl , 'root' => $ aliases [ 'default' ] [ 'root' ] , ) ; } //end if $ aliasesArray = "<?php \n\n\$aliases = " . var_export ( $ aliases , true ) . ";" ; if ( file_put_contents ( $ aliasesFile , $ aliasesArray ) ) { $ this -> log ( "Succesfully wrote aliases to file '" . $ aliasesFile . "'" , Project :: MSG_INFO ) ; } else { $ this -> log ( "Was unable to write aliases to file '" . $ aliasesFile . "'" , Project :: MSG_WARN ) ; } }
Generates an aliases.drushrc.php file.

Either generates a file for:
- all sites in the sites directory.
- a single site to be added to the aliases file (appending).

@return void
Generates an aliases . drushrc . php file .