Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #159 from basz/hotfix/zf2-develop-aware-change-for…

…-controller

accommodate ServiceLocatorAwareInterface
  • Loading branch information...
commit ee184439b7f5e4c9f7545ad1e528e789fdadc98b 2 parents 35ef380 + 301f554
Rob Allen akrabat authored
17 Module.php
View
@@ -31,6 +31,23 @@ public function getConfig($env = null)
return include __DIR__ . '/config/module.config.php';
}
+ public function getControllerPluginConfig()
+ {
+ return array(
+ 'factories' => array(
+ 'zfcUserAuthentication' => function ($sm) {
+ $serviceLocator = $sm->getServiceLocator();
+ $authService = $serviceLocator->get('zfcuser_auth_service');
+ $authAdapter = $serviceLocator->get('ZfcUser\Authentication\Adapter\AdapterChain');
+ $controllerPlugin = new Controller\Plugin\ZfcUserAuthentication;
+ $controllerPlugin->setAuthService($authService);
+ $controllerPlugin->setAuthAdapter($authAdapter);
+ return $controllerPlugin;
+ },
+ ),
+ );
+ }
+
public function getViewHelperConfig()
{
return array(
5 config/module.config.php
View
@@ -10,11 +10,6 @@
'zfcuser' => 'ZfcUser\Controller\UserController',
),
),
- 'controller_plugins' => array(
- 'invokables' => array(
- 'zfcuserauthentication' => 'ZfcUser\Controller\Plugin\ZfcUserAuthentication',
- ),
- ),
'service_manager' => array(
'aliases' => array(
'zfcuser_zend_db_adapter' => 'Zend\Db\Adapter\Adapter',
37 src/ZfcUser/Controller/Plugin/ZfcUserAuthentication.php
View
@@ -4,11 +4,10 @@
use Zend\Mvc\Controller\Plugin\AbstractPlugin;
use Zend\Authentication\AuthenticationService;
-use Zend\ServiceManager\ServiceManagerAwareInterface;
-use Zend\ServiceManager\ServiceManager;
+use Zend\ServiceManager\ServiceLocatorInterface;
use ZfcUser\Authentication\Adapter\AdapterChain as AuthAdapter;
-class ZfcUserAuthentication extends AbstractPlugin implements ServiceManagerAwareInterface
+class ZfcUserAuthentication extends AbstractPlugin
{
/**
* @var AuthAdapter
@@ -21,10 +20,10 @@ class ZfcUserAuthentication extends AbstractPlugin implements ServiceManagerAwar
protected $authService;
/**
- * @var ServiceManager
+ * @var ServiceLocatorInterface
*/
- protected $serviceManager;
-
+ protected $serviceLocator;
+
/**
* Proxy convenience method
*
@@ -52,9 +51,6 @@ public function getIdentity()
*/
public function getAuthAdapter()
{
- if (null === $this->authAdapter) {
- $this->authAdapter = $this->getServiceManager()->get('ZfcUser\Authentication\Adapter\AdapterChain');
- }
return $this->authAdapter;
}
@@ -76,9 +72,6 @@ public function setAuthAdapter(AuthAdapter $authAdapter)
*/
public function getAuthService()
{
- if (null === $this->authService) {
- $this->authService = $this->getServiceManager()->get('zfcuser_auth_service');
- }
return $this->authService;
}
@@ -93,24 +86,4 @@ public function setAuthService(AuthenticationService $authService)
return $this;
}
- /**
- * Retrieve service manager instance
- *
- * @return ServiceManager
- */
- public function getServiceManager()
- {
- return $this->serviceManager->getServiceLocator();
- }
-
- /**
- * Set service manager instance
- *
- * @param ServiceManager $locator
- * @return void
- */
- public function setServiceManager(ServiceManager $serviceManager)
- {
- $this->serviceManager = $serviceManager;
- }
}
Please sign in to comment.
Something went wrong with that request. Please try again.