Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
HelperSet.php
001 <?php
002
003 /*
004 * This file is part of the Symfony package.
005 *
006 * (c) Fabien Potencier <fabien@symfony.com>
007 *
008 * For the full copyright and license information, please view the LICENSE
009 * file that was distributed with this source code.
010 */
011
012 namespace Symfony\Component\Console\Helper;
013
014 use Symfony\Component\Console\Command\Command;
015 use Symfony\Component\Console\Exception\InvalidArgumentException;
016
017 /**
018 * HelperSet represents a set of helpers to be used with a command.
019 *
020 * @author Fabien Potencier <fabien@symfony.com>
021 */
022 class HelperSet implements \IteratorAggregate
023 {
024 /**
025 * @var Helper[]
026 */
027 private $helpers = [];
028 private $command;
029
030 /**
031 * @param Helper[] $helpers An array of helper
032 */
033 public function __construct(array $helpers = [])
034 {
035 foreach ($helpers as $alias => $helper) {
036 $this->set($helper, \is_int($alias) ? null : $alias);
037 }
038 }
039
040 /**
041 * Sets a helper.
042 *
043 * @param HelperInterface $helper The helper instance
044 * @param string $alias An alias
045 */
046 public function set(HelperInterface $helper, $alias = null)
047 {
048 $this->helpers[$helper->getName()] = $helper;
049 if (null !== $alias) {
050 $this->helpers[$alias] = $helper;
051 }
052
053 $helper->setHelperSet($this);
054 }
055
056 /**
057 * Returns true if the helper if defined.
058 *
059 * @param string $name The helper name
060 *
061 * @return bool true if the helper is defined, false otherwise
062 */
063 public function has($name)
064 {
065 return isset($this->helpers[$name]);
066 }
067
068 /**
069 * Gets a helper value.
070 *
071 * @param string $name The helper name
072 *
073 * @return HelperInterface The helper instance
074 *
075 * @throws InvalidArgumentException if the helper is not defined
076 */
077 public function get($name)
078 {
079 if (!$this->has($name)) {
080 throw new InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name));
081 }
082
083 return $this->helpers[$name];
084 }
085
086 public function setCommand(Command $command = null)
087 {
088 $this->command = $command;
089 }
090
091 /**
092 * Gets the command associated with this helper set.
093 *
094 * @return Command A Command instance
095 */
096 public function getCommand()
097 {
098 return $this->command;
099 }
100
101 /**
102 * @return Helper[]
103 */
104 public function getIterator()
105 {
106 return new \ArrayIterator($this->helpers);
107 }
108 }
109