[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /* 4 * This file is part of the Symfony package. 5 * 6 * (c) Fabien Potencier <[email protected]> 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 <[email protected]> 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 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |