Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

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.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

HelperSet.php

Zuletzt modifiziert: 09.10.2024, 12:56 - Dateigröße: 3.50 KiB


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 = array();
028      private $command;
029   
030      /**
031       * Constructor.
032       *
033       * @param Helper[] $helpers An array of helper
034       */
035      public function __construct(array $helpers = array())
036      {
037          foreach ($helpers as $alias => $helper) {
038              $this->set($helper, is_int($alias) ? null : $alias);
039          }
040      }
041   
042      /**
043       * Sets a helper.
044       *
045       * @param HelperInterface $helper The helper instance
046       * @param string          $alias  An alias
047       */
048      public function set(HelperInterface $helper, $alias = null)
049      {
050          $this->helpers[$helper->getName()] = $helper;
051          if (null !== $alias) {
052              $this->helpers[$alias] = $helper;
053          }
054   
055          $helper->setHelperSet($this);
056      }
057   
058      /**
059       * Returns true if the helper if defined.
060       *
061       * @param string $name The helper name
062       *
063       * @return bool true if the helper is defined, false otherwise
064       */
065      public function has($name)
066      {
067          return isset($this->helpers[$name]);
068      }
069   
070      /**
071       * Gets a helper value.
072       *
073       * @param string $name The helper name
074       *
075       * @return HelperInterface The helper instance
076       *
077       * @throws InvalidArgumentException if the helper is not defined
078       */
079      public function get($name)
080      {
081          if (!$this->has($name)) {
082              throw new InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name));
083          }
084   
085          if ('dialog' === $name && $this->helpers[$name] instanceof DialogHelper) {
086              @trigger_error('"Symfony\Component\Console\Helper\DialogHelper" is deprecated since version 2.5 and will be removed in 3.0. Use "Symfony\Component\Console\Helper\QuestionHelper" instead.', E_USER_DEPRECATED);
087          } elseif ('progress' === $name && $this->helpers[$name] instanceof ProgressHelper) {
088              @trigger_error('"Symfony\Component\Console\Helper\ProgressHelper" is deprecated since version 2.5 and will be removed in 3.0. Use "Symfony\Component\Console\Helper\ProgressBar" instead.', E_USER_DEPRECATED);
089          } elseif ('table' === $name && $this->helpers[$name] instanceof TableHelper) {
090              @trigger_error('"Symfony\Component\Console\Helper\TableHelper" is deprecated since version 2.5 and will be removed in 3.0. Use "Symfony\Component\Console\Helper\Table" instead.', E_USER_DEPRECATED);
091          }
092   
093          return $this->helpers[$name];
094      }
095   
096      /**
097       * Sets the command associated with this helper set.
098       *
099       * @param Command $command A Command instance
100       */
101      public function setCommand(Command $command = null)
102      {
103          $this->command = $command;
104      }
105   
106      /**
107       * Gets the command associated with this helper set.
108       *
109       * @return Command A Command instance
110       */
111      public function getCommand()
112      {
113          return $this->command;
114      }
115   
116      /**
117       * @return Helper[]
118       */
119      public function getIterator()
120      {
121          return new \ArrayIterator($this->helpers);
122      }
123  }
124