Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
<?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);
}
}
<?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);
}
}
<?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()
));
}
}
<?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);
}
}
<?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