use zend router
[GitHub/Stricted/Domain-Control-Panel.git] / vendor / Zend / Mvc / Controller / Plugin / Service / ForwardFactory.php
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
4 *
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
8 */
9
10 namespace Zend\Mvc\Controller\Plugin\Service;
11
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;
17
18 class ForwardFactory implements FactoryInterface
19 {
20 /**
21 * {@inheritDoc}
22 *
23 * @return Forward
24 * @throws ServiceNotCreatedException if Controllermanager service is not found in application service locator
25 */
26 public function __invoke(ContainerInterface $container, $name, array $options = null)
27 {
28 if (! $container->has('ControllerManager')) {
29 throw new ServiceNotCreatedException(sprintf(
30 '%s requires that the application service manager contains a "%s" service; none found',
31 __CLASS__,
32 'ControllerManager'
33 ));
34 }
35 $controllers = $container->get('ControllerManager');
36
37 return new Forward($controllers);
38 }
39
40 /**
41 * Create and return Forward instance
42 *
43 * For use with zend-servicemanager v2; proxies to __invoke().
44 *
45 * @param ServiceLocatorInterface $container
46 * @return Forward
47 */
48 public function createService(ServiceLocatorInterface $container)
49 {
50 $parentContainer = $container->getServiceLocator() ?: $container;
51 return $this($parentContainer, Forward::class);
52 }
53 }