628ae966c29ef90b8d30f444f441b8485ff8251f
[GitHub/Stricted/Domain-Control-Panel.git] / vendor / Zend / Mvc / Service / ConsoleRouteNotFoundStrategyFactory.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\View\Console\RouteNotFoundStrategy;
14 use Zend\ServiceManager\FactoryInterface;
15 use Zend\ServiceManager\ServiceLocatorInterface;
16
17 class ConsoleRouteNotFoundStrategyFactory implements FactoryInterface
18 {
19 use ConsoleViewManagerConfigTrait;
20
21 /**
22 * @param ContainerInterface $container
23 * @param string $name
24 * @param null|array $options
25 * @return RouteNotFoundStrategy
26 */
27 public function __invoke(ContainerInterface $container, $name, array $options = null)
28 {
29 $strategy = new RouteNotFoundStrategy();
30 $config = $this->getConfig($container);
31
32 $this->injectDisplayNotFoundReason($strategy, $config);
33
34 return $strategy;
35 }
36
37 /**
38 * Create and return RouteNotFoundStrategy instance
39 *
40 * @param ServiceLocatorInterface $container
41 * @return RouteNotFoundStrategy
42 */
43 public function createService(ServiceLocatorInterface $container)
44 {
45 return $this($container, RouteNotFoundStrategy::class);
46 }
47
48 /**
49 * Inject strategy with configured display_not_found_reason flag.
50 *
51 * @param RouteNotFoundStrategy $strategy
52 * @param array $config
53 */
54 private function injectDisplayNotFoundReason(RouteNotFoundStrategy $strategy, array $config)
55 {
56 $flag = array_key_exists('display_not_found_reason', $config) ? $config['display_not_found_reason'] : true;
57 $strategy->setDisplayNotFoundReason($flag);
58 }
59 }