3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\Mvc\Controller\Plugin\Service
;
12 use Interop\Container\ContainerInterface
;
13 use Zend\ServiceManager\Exception\ServiceNotCreatedException
;
14 use Zend\ServiceManager\FactoryInterface
;
15 use Zend\ServiceManager\ServiceLocatorInterface
;
16 use Zend\Mvc\Controller\Plugin\Forward
;
18 class ForwardFactory
implements FactoryInterface
24 * @throws ServiceNotCreatedException if Controllermanager service is not found in application service locator
26 public function __invoke(ContainerInterface
$container, $name, array $options = null)
28 if (! $container->has('ControllerManager')) {
29 throw new ServiceNotCreatedException(sprintf(
30 '%s requires that the application service manager contains a "%s" service; none found',
35 $controllers = $container->get('ControllerManager');
37 return new Forward($controllers);
41 * Create and return Forward instance
43 * For use with zend-servicemanager v2; proxies to __invoke().
45 * @param ServiceLocatorInterface $container
48 public function createService(ServiceLocatorInterface
$container)
50 $parentContainer = $container->getServiceLocator() ?
: $container;
51 return $this($parentContainer, Forward
::class);