Commit 2d8dc9b8 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Suppression services jamais utilisés.

parent 0ba8e633
<?php
namespace UnicaenAuth\Authentication\Service;
use UnicaenAuth\Authentication\Strategy\StrategyInterface;
use Zend\EventManager\EventManager;
use Zend\EventManager\EventManagerAwareInterface;
use Zend\EventManager\EventManagerInterface;
use Zend\ServiceManager\ServiceManager;
use Zend\ServiceManager\ServiceManagerAwareInterface;
use ZfcUser\Authentication\Adapter\AbstractAdapter;
use ZfcUser\Authentication\Adapter\AdapterChainEvent;
/**
*
*
* @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
*/
class StrategyService extends AbstractAdapter implements ServiceManagerAwareInterface, EventManagerAwareInterface
{
/**
* @var StrategyInterface
*/
protected $strategy;
/**
* @var ServiceManager
*/
protected $serviceManager;
/**
* @var EventManager
*/
protected $eventManager;
/**
*
* @param StrategyInterface $strategy
*/
public function __construct(StrategyInterface $strategy = null)
{
$this->setStrategy($strategy);
}
/**
*
* @param AdapterChainEvent $e
* @return boolean
*/
public function authenticate(AdapterChainEvent $e)
{
$casAdapter->getEventManager()->attach('userAuthenticated', array($userService, 'userAuthenticated'), 1);
$this->getStrategy()->authenticate($e);
die(__METHOD__);
}
/**
*
*
* @return StrategyInterface
*/
public function getStrategy()
{
return $this->strategy;
}
/**
*
*
* @param StrategyInterface $strategy
* @return StrategyService
*/
public function setStrategy(StrategyInterface $strategy)
{
$this->strategy = $strategy;
return $this;
}
/**
* Retrieve service manager instance
*
* @return ServiceManager
*/
public function getServiceManager()
{
return $this->serviceManager;
}
/**
* Set service manager
*
* @param ServiceManager $serviceManager
* @return StrategyService
*/
public function setServiceManager(ServiceManager $serviceManager)
{
$this->serviceManager = $serviceManager;
return $this;
}
/**
* Retrieve EventManager instance
*
* @return EventManagerInterface
*/
public function getEventManager()
{
return $this->eventManager;
}
/**
* Inject an EventManager instance
*
* @param EventManagerInterface $eventManager
* @return StrategyService
*/
public function setEventManager(EventManagerInterface $eventManager)
{
$this->eventManager = $eventManager;
return $this;
}
}
\ No newline at end of file
<?php
namespace UnicaenAuth\Authentication\Service;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
/**
*
*
* @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
*/
class StrategyServiceFactory implements FactoryInterface
{
/**
* Create service
*
* @param ServiceLocatorInterface $serviceLocator
* @return mixed
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$strategy = $serviceLocator->get('UnicaenAuth\Authentication\Strategy\Strategy');
return new StrategyService($strategy);
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment