XF 2.0 Using option to change URL

Matt C.

Well-known member
I'm making a battle.net integration add-on, and I need to be able to distinguish between different regions via the options.

I was wondering if there was a better way do it than this?

Code:
$this->options = \XF::options();
if ($this->options->ah_bn_region == 'us')
{
    $url = 'https://us.battle.net';
}
elseif ($this->options->ah_bn_region == 'eu')
{
    $url = 'https://eu.battle.net';
}
else
{
    $url = 'https://apac.battle.net';
}

if (null === $baseApiUri) {
    $this->baseApiUri = new Uri($url);
}

Thank you!
 
PHP:
switch (\XF::options()->ah_bn_region)
{
    case 'us':
        $url = 'https://us.battle.net';
        break;
    case 'eu':
        $url = 'https://eu.battle.net';
        break;
    case 'apac':
        $url = 'https://apac.battle.net';
        break;
}

Would read better, IMO.
 
Back
Top Bottom