PluginProbe
WP-Stateless – Google Cloud Storage / 3.2.2
WP-Stateless – Google Cloud Storage v3.2.2
4.4.3 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.3.0 2.3.1 2.3.2 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.2.0 3.2.1 3.2.2 All 62 releases
wp-stateless / vendor / symfony / console / CommandLoader / ContainerCommandLoader.php

ContainerCommandLoader.php in WP-Stateless – Google Cloud Storage 3.2.2, at vendor/symfony/console/CommandLoader/ContainerCommandLoader.php

64 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\Console\CommandLoader;
13
14 use Psr\Container\ContainerInterface;
15 use Symfony\Component\Console\Exception\CommandNotFoundException;
16
17 /**
18 * Loads commands from a PSR-11 container.
19 *
20 * @author Robin Chalas <robin.chalas@gmail.com>
21 */
22 class ContainerCommandLoader implements CommandLoaderInterface
23 {
24 private $container;
25 private $commandMap;
26
27 /**
28 * @param array $commandMap An array with command names as keys and service ids as values
29 */
30 public function __construct(ContainerInterface $container, array $commandMap)
31 {
32 $this->container = $container;
33 $this->commandMap = $commandMap;
34 }
35
36 /**
37 * {@inheritdoc}
38 */
39 public function get(string $name)
40 {
41 if (!$this->has($name)) {
42 throw new CommandNotFoundException(sprintf('Command "%s" does not exist.', $name));
43 }
44
45 return $this->container->get($this->commandMap[$name]);
46 }
47
48 /**
49 * {@inheritdoc}
50 */
51 public function has(string $name)
52 {
53 return isset($this->commandMap[$name]) && $this->container->has($this->commandMap[$name]);
54 }
55
56 /**
57 * {@inheritdoc}
58 */
59 public function getNames()
60 {
61 return array_keys($this->commandMap);
62 }
63 }
64