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\Service
;
12 use Interop\Container\ContainerInterface
;
13 use Zend\Console\Console
;
14 use Zend\ServiceManager\Exception\ServiceNotCreatedException
;
15 use Zend\ServiceManager\FactoryInterface
;
16 use Zend\ServiceManager\ServiceLocatorInterface
;
17 use Zend\Mvc\View\Console\ViewManager
as ConsoleViewManager
;
19 class ConsoleViewManagerFactory
implements FactoryInterface
22 * Create and return the view manager for the console environment
24 * @param ContainerInterface $container
26 * @param null|array $options
27 * @return ConsoleViewManager
29 public function __invoke(ContainerInterface
$container, $name, array $options = null)
31 if (! Console
::isConsole()) {
32 throw new ServiceNotCreatedException(
33 'ConsoleViewManager requires a Console environment; console environment not detected'
37 return new ConsoleViewManager();
41 * Create and return ConsoleViewManager instance
43 * For use with zend-servicemanager v2; proxies to __invoke().
45 * @param ServiceLocatorInterface $container
46 * @return ConsoleViewManager
48 public function createService(ServiceLocatorInterface
$container)
50 return $this($container, ConsoleViewManager
::class);