public function getLoginUrl(LinkedInUrlGeneratorInterface $urlGenerator, $options = [])
{
// Generate a state
$this->establishCSRFTokenState();
// Build request params
$requestParams = array_merge(['response_type' => 'code', 'client_id' => $this->appId, 'state' => $this->getStorage()->get('state'), 'redirect_uri' => null], $options);
// Save the redirect url for later
$this->getStorage()->set('redirect_uri', $requestParams['redirect_uri']);
// if 'scope' is passed as an array, convert to space separated list
$scopeParams = isset($options['scope']) ? $options['scope'] : null;
if ($scopeParams) {
//if scope is an array
if (is_array($scopeParams)) {
$requestParams['scope'] = implode(' ', $scopeParams);
} elseif (is_string($scopeParams)) {
//if scope is a string with ',' => make it to an array
$requestParams['scope'] = str_replace(',', ' ', $scopeParams);
}
}
return $urlGenerator->getUrl('www', 'oauth/v2/authorization', $requestParams);
}