Platformsh\Cli\Command\Tunnel\TunnelCommandBase::filterTunnels PHP Method

filterTunnels() protected method

Filter a list of tunnels by the currently selected project/environment.
protected filterTunnels ( array $tunnels, Symfony\Component\Console\Input\InputInterface $input ) : array
$tunnels array
$input Symfony\Component\Console\Input\InputInterface
return array
    protected function filterTunnels(array $tunnels, InputInterface $input)
    {
        if (!$input->getOption('project') && !$this->getProjectRoot()) {
            return $tunnels;
        }
        if (!$this->hasSelectedProject()) {
            $this->validateInput($input, true);
        }
        $project = $this->getSelectedProject();
        $environment = $this->hasSelectedEnvironment() ? $this->getSelectedEnvironment() : null;
        $appName = $this->selectApp($input);
        foreach ($tunnels as $key => $tunnel) {
            if ($tunnel['projectId'] !== $project->id || $environment !== null && $tunnel['environmentId'] !== $environment->id || $appName !== null && $tunnel['appName'] !== $appName) {
                unset($tunnels[$key]);
            }
        }
        return $tunnels;
    }