Skip to content

Commit

Permalink
I have solved the #234 issue in this way.
Browse files Browse the repository at this point in the history
I have added in the UserController a protected variable and I have created a setter and a getter method. I have edited the UserControllerFactory.php catching the service and I have set it up in the UserController instance.

 If it is not good, please show me a solution.
  • Loading branch information
shinesoftware committed Aug 6, 2016
1 parent eb90726 commit 9c49e03
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
29 changes: 26 additions & 3 deletions src/ScnSocialAuth/Controller/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ class UserController extends AbstractActionController
*/
protected $options;

/**
* @var zfcmoduleoptions
*/
protected $zfcmoduleoptions;


/*
* @todo Make this dynamic / translation-friendly
* @var string
Expand Down Expand Up @@ -96,7 +102,7 @@ public function providerLoginAction()
$hybridAuth = $this->getHybridAuth();

$query = array();
if ($this->getServiceLocator()->get('zfcuser_module_options')->getUseRedirectParameterIfPresent() && $this->getRequest()->getQuery()->get('redirect')) {
if ($this->getZfcModuleOptions()->getUseRedirectParameterIfPresent() && $this->getRequest()->getQuery()->get('redirect')) {
$query = array('redirect' => $this->getRequest()->getQuery()->get('redirect'));
}
$redirectUrl = $this->url()->fromRoute('scn-social-auth-user/authenticate/provider', array('provider' => $provider), array('query' => $query));
Expand Down Expand Up @@ -124,7 +130,7 @@ public function loginAction()
$viewModel->setVariable('options', $this->getOptions());

$redirect = false;
if ($this->getServiceLocator()->get('zfcuser_module_options')->getUseRedirectParameterIfPresent() && $this->getRequest()->getQuery()->get('redirect')) {
if ($this->getZfcModuleOptions()->getUseRedirectParameterIfPresent() && $this->getRequest()->getQuery()->get('redirect')) {
$redirect = $this->getRequest()->getQuery()->get('redirect');
}
$viewModel->setVariable('redirect', $redirect);
Expand Down Expand Up @@ -173,7 +179,7 @@ public function registerAction()
$viewModel->setVariable('options', $this->getOptions());

$redirect = false;
if ($this->getServiceLocator()->get('zfcuser_module_options')->getUseRedirectParameterIfPresent() && $this->getRequest()->getQuery()->get('redirect')) {
if ($this->getZfcModuleOptions()->getUseRedirectParameterIfPresent() && $this->getRequest()->getQuery()->get('redirect')) {
$redirect = $this->getRequest()->getQuery()->get('redirect');
}
$viewModel->setVariable('redirect', $redirect);
Expand Down Expand Up @@ -261,4 +267,21 @@ public function getOptions()

return $this->options;
}


/**
* @return zfcmoduleoptions
*/
public function getZfcModuleOptions()
{
return $this->zfcmoduleoptions;
}

/**
* @param zfcmoduleoptions $zfcmoduleoptions
*/
public function setZfcModuleOptions($zfcmoduleoptions)
{
$this->zfcmoduleoptions = $zfcmoduleoptions;
}
}
2 changes: 2 additions & 0 deletions src/ScnSocialAuth/Service/UserControllerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ public function createService(ServiceLocatorInterface $controllerManager)
$mapper = $controllerManager->getServiceLocator()->get('ScnSocialAuth-UserProviderMapper');
$moduleOptions = $controllerManager->getServiceLocator()->get('ScnSocialAuth-ModuleOptions');
$redirectCallback = $controllerManager->getServiceLocator()->get('zfcuser_redirect_callback');
$zfcuserModuleOptions = $controllerManager->getServiceLocator()->get('zfcuser_module_options');

$controller = new UserController($redirectCallback);
$controller->setMapper($mapper);
$controller->setOptions($moduleOptions);
$controller->setZfcModuleOptions($zfcuserModuleOptions);

try {
$hybridAuth = $controllerManager->getServiceLocator()->get('HybridAuth');
Expand Down

0 comments on commit 9c49e03

Please sign in to comment.