use zend router
[GitHub/Stricted/Domain-Control-Panel.git] / vendor / Zend / Mvc / Service / HttpRouterFactory.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\Service;
11
12 use Interop\Container\ContainerInterface;
13 use Zend\Mvc\Router\RouteStackInterface;
14 use Zend\ServiceManager\FactoryInterface;
15 use Zend\ServiceManager\ServiceLocatorInterface;
16
17 class HttpRouterFactory implements FactoryInterface
18 {
19 use RouterConfigTrait;
20
21 /**
22 * Create and return the HTTP router
23 *
24 * Retrieves the "router" key of the Config service, and uses it
25 * to instantiate the router. Uses the TreeRouteStack implementation by
26 * default.
27 *
28 * @param ContainerInterface $container
29 * @param string $name
30 * @param null|array $options
31 * @return RouteStackInterface
32 */
33 public function __invoke(ContainerInterface $container, $name, array $options = null)
34 {
35 $config = $container->has('config') ? $container->get('config') : [];
36
37 // Defaults
38 $class = 'Zend\Mvc\Router\Http\TreeRouteStack';
39 $config = isset($config['router']) ? $config['router'] : [];
40
41 return $this->createRouter($class, $config, $container);
42 }
43
44 /**
45 * Create and return RouteStackInterface instance
46 *
47 * For use with zend-servicemanager v2; proxies to __invoke().
48 *
49 * @param ServiceLocatorInterface $container
50 * @return RouteStackInterface
51 */
52 public function createService(ServiceLocatorInterface $container)
53 {
54 return $this($container, RouteStackInterface::class);
55 }
56 }