This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace SocialAuth\Adapter; | |
class HybridAuthAdapter | |
{ | |
protected $hybridAuth; | |
public function __construct($hybridAuth) | |
{ | |
$this->hybridAuth = $hybridAuth; | |
} | |
public function getHyBridAuth() | |
{ | |
return $this->hybridAuth; | |
} | |
public function authenticate($providerId) | |
{ | |
return $this->getHyBridAuth()->authenticate($providerId); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace SocialAuth\Adapter\Factory; | |
use Zend\ServiceManager\ServiceLocatorInterface; | |
use SocialAuth\Adapter\HybridAuthAdapter; | |
class HybridAuthAdapterFactory | |
{ | |
public function __invoke(ServiceLocatorInterface $services) | |
{ | |
$hybridAuth = $services->get('SocialAuth\HybridAuth'); | |
return new HybridAuthAdapter($hybridAuth); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace SocialAuth\Controller; | |
use Zend\Mvc\Controller\AbstractActionController; | |
use Zend\View\Model\ViewModel; | |
class IndexController extends AbstractActionController { | |
protected $hybridAuthAdapter; | |
public function __construct($hybridAuthAdapter) { | |
$this->hybridAuthAdapter = $hybridAuthAdapter; | |
} | |
public function indexAction() | |
{ | |
$provider = $this->hybridAuthAdapter->authenticate('Twitter'); | |
return new ViewModel(array( | |
'profile' => $provider->getUserProfile() | |
)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace SocialAuth\Controller\Factory; | |
use SocialAuth\Controller\IndexController; | |
class IndexControllerFactory | |
{ | |
public function __invoke($controllers) | |
{ | |
$services = $controllers->getServiceLocator(); | |
$hybridAuthAdapter = $services->get('SocialAuth\Adapter\HybridAuthAdapter'); | |
return new IndexController($hybridAuthAdapter); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
return array( | |
'service_manager' => array( | |
'factories' => array( | |
'LazyServiceFactory' => 'Zend\ServiceManager\Proxy\LazyServiceFactoryFactory', | |
'SocialAuth\Adapter\HybridAuthAdapter' => 'SocialAuth\Adapter\Factory\HybridAuthAdapterFactory', | |
'SocialAuth\HybridAuth' => 'SocialAuth\Service\Factory\HybridAuthFactory', | |
), | |
'delegators' => array( | |
'SocialAuth\Adapter\HybridAuthAdapter' => array( | |
'LazyServiceFactory' | |
), | |
), | |
), | |
'lazy_services' => array( | |
'class_map' => array( | |
'SocialAuth\Adapter\HybridAuthAdapter' => 'SocialAuth\Adapter\HybridAuthAdapter', | |
), | |
), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment