src/Service/IndexControllerFactory.php
<?php
/**
* Copyright (c)2012-2013 heiglandreas
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIBILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @category HybridAuth
* @author Andreas Heigl<andreas@heigl.org>
* @copyright ©2012-2013 Andreas Heigl
* @license http://www.opesource.org/licenses/mit-license.php MIT-License
* @version 0.0
* @since 11.01.13
* @link https://github.com/heiglandreas/HybridAuth
*/
namespace OrgHeiglHybridAuth\Service;
use Interop\Container\ContainerInterface;
use Interop\Container\Exception\ContainerException;
use OrgHeiglHybridAuth\Controller\IndexController;
use OrgHeiglHybridAuth\UserWrapperFactory;
use Zend\ServiceManager\Exception\ServiceNotCreatedException;
use Zend\ServiceManager\Exception\ServiceNotFoundException;
use Zend\ServiceManager\Factory\FactoryInterface;
/**
* Create an instance of the session
*
* @category HybridAuth
* @author Andreas Heigl<andreas@heigl.org>
* @copyright ©2012-2013 Andreas Heigl
* @license http://www.opesource.org/licenses/mit-license.php MIT-License
* @version 0.0
* @since 11.01.13
* @link https://github.com/heiglandreas/HybridAuth
*/
class IndexControllerFactory implements FactoryInterface
{
/**
* Create an object
*
* @param ContainerInterface $container
* @param string $requestedName
* @param null|array $options
*
* @return object
* @throws ServiceNotFoundException if unable to resolve the service.
* @throws ServiceNotCreatedException if an exception is raised when
* creating a service.
* @throws ContainerException if any other error occurs
*/
public function __invoke(
ContainerInterface $container,
$requestedName,
array $options = null
) {
$authenticator = $container->get('OrgHeiglHybridAuthBackend');
$session = $container->get('OrgHeiglHybridAuthSession');
$wrapperFactory = $container->get(UserWrapperFactory::class);
$controller = new IndexController();
$controller->setSession($session)
->setAuthenticator($authenticator)
->setUserWrapperFactory($wrapperFactory);
return $controller;
}
}