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\Mvc\View\Console\RouteNotFoundStrategy
;
14 use Zend\ServiceManager\FactoryInterface
;
15 use Zend\ServiceManager\ServiceLocatorInterface
;
17 class ConsoleRouteNotFoundStrategyFactory
implements FactoryInterface
19 use ConsoleViewManagerConfigTrait
;
22 * @param ContainerInterface $container
24 * @param null|array $options
25 * @return RouteNotFoundStrategy
27 public function __invoke(ContainerInterface
$container, $name, array $options = null)
29 $strategy = new RouteNotFoundStrategy();
30 $config = $this->getConfig($container);
32 $this->injectDisplayNotFoundReason($strategy, $config);
38 * Create and return RouteNotFoundStrategy instance
40 * @param ServiceLocatorInterface $container
41 * @return RouteNotFoundStrategy
43 public function createService(ServiceLocatorInterface
$container)
45 return $this($container, RouteNotFoundStrategy
::class);
49 * Inject strategy with configured display_not_found_reason flag.
51 * @param RouteNotFoundStrategy $strategy
52 * @param array $config
54 private function injectDisplayNotFoundReason(RouteNotFoundStrategy
$strategy, array $config)
56 $flag = array_key_exists('display_not_found_reason', $config) ?
$config['display_not_found_reason'] : true;
57 $strategy->setDisplayNotFoundReason($flag);