Pantheon\Terminus\Commands\Domain\LookupCommand::lookup PHP Method

lookup() public method

Looks up which environment a given domain is associated with
public lookup ( string $domain ) : Consolidation\OutputFormatters\StructuredData\PropertyList
$domain string The domain to search your site environments for
return Consolidation\OutputFormatters\StructuredData\PropertyList
    public function lookup($domain)
    {
        $this->log()->notice('This operation may take a long time to run.');
        $sites = $this->sites()->fetch()->all();
        $environments = ['dev', 'test', 'live'];
        foreach ($sites as $site_id => $site) {
            foreach ($environments as $env_name) {
                if ($site->getEnvironments()->get($env_name)->getDomains()->fetch()->has($domain)) {
                    $env = ['site_id' => $site->id, 'site_name' => $site->get('name'), 'env_id' => $env_name];
                    break 2;
                }
            }
        }
        if (!isset($env)) {
            throw new TerminusNotFoundException('Could not locate an environment with the domain {domain}.', compact('domain'));
        }
        return new PropertyList($env);
    }
LookupCommand