CraftCli\Command\DbPullCommand::validate PHP 메소드

validate() 보호된 메소드

Validate environments/config
protected validate ( ) : void
리턴 void
    protected function validate()
    {
        $dbConfig = (require $this->configPath . 'db.php');
        if (!isset($dbConfig['*'])) {
            throw new Exception('Could not find a multi-environment configuration in your db.php.');
        }
        $remoteEnvironment = $this->argument('remote-environment');
        $this->localCredentials = $this->remoteCredentials = $dbConfig['*'];
        if (isset($dbConfig[$this->environment])) {
            $this->localCredentials = array_merge($this->localCredentials, $dbConfig[$this->environment]);
        }
        if (isset($dbConfig[$remoteEnvironment])) {
            $this->remoteCredentials = array_merge($this->remoteCredentials, $dbConfig[$remoteEnvironment]);
        }
        $this->debug = $this->option('debug');
        if (!$this->debug && !$this->option('force') && !$this->confirm('This will overwrite your local database. Are you sure you want to continue?')) {
            throw new Exception('Transfer cancelled.');
        }
        if ($this->option('ssh-host')) {
            $this->sshCredentials = ['host' => $this->option('ssh-host')];
            if ($this->option('ssh-user')) {
                $this->sshCredentials['user'] = $this->option('ssh-user');
            }
            if ($this->option('ssh-port')) {
                $this->sshCredentials['port'] = $this->option('ssh-port');
            }
            if ($this->option('ssh-identity-file')) {
                $this->sshCredentials['identityFile'] = $this->option('ssh-identity-file');
            }
        }
        // test the local db credentials
        $this->info('Testing local database credentials...');
        if (!$this->testLocalCredentials()) {
            throw new Exception('Could not connect to local mysql database.');
        }
        // test the ssh credentials
        if ($this->sshCredentials) {
            $this->info('Testing SSH credentials...');
            if (!$this->testSshCredentials()) {
                throw new Exception('Could not connect to remote server via SSH.');
            }
        }
        // test the remote db credentials
        $this->info('Testing remote database credentials...');
        if (!$this->testRemoteCredentials()) {
            throw new Exception('Could not connect to remote mysql database.');
        }
    }