use zend router
[GitHub/Stricted/Domain-Control-Panel.git] / vendor / Zend / Mvc / Service / ViewManagerFactory.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\Console\Console;
14 use Zend\Mvc\View\Console\ViewManager as ConsoleViewManager;
15 use Zend\Mvc\View\Http\ViewManager as HttpViewManager;
16 use Zend\ServiceManager\FactoryInterface;
17 use Zend\ServiceManager\ServiceLocatorInterface;
18
19 class ViewManagerFactory implements FactoryInterface
20 {
21 /**
22 * Create and return a view manager based on detected environment
23 *
24 * @param ContainerInterface $container
25 * @param string $name
26 * @param null|array $options
27 * @return ConsoleViewManager|HttpViewManager
28 */
29 public function __invoke(ContainerInterface $container, $name, array $options = null)
30 {
31 if (Console::isConsole()) {
32 return $container->get('ConsoleViewManager');
33 }
34
35 return $container->get('HttpViewManager');
36 }
37
38 /**
39 * Create and return HttpViewManager or ConsoleViewManager instance
40 *
41 * For use with zend-servicemanager v2; proxies to __invoke().
42 *
43 * @param ServiceLocatorInterface $container
44 * @return HttpViewManager|ConsoleViewManager
45 */
46 public function createService(ServiceLocatorInterface $container)
47 {
48 $type = Console::isConsole() ? ConsoleViewManager::class : HttpViewManager::class;
49 return $this($container, $type);
50 }
51 }