Verzeichnisstruktur phpBB-3.1.0


Veröffentlicht
27.10.2014

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:58 - Dateigröße: 2.37 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   
 016  /**
 017   * HelperSet represents a set of helpers to be used with a command.
 018   *
 019   * @author Fabien Potencier <fabien@symfony.com>
 020   */
 021  class HelperSet
 022  {
 023      private $helpers;
 024      private $command;
 025   
 026      /**
 027       * Constructor.
 028       *
 029       * @param Helper[] $helpers An array of helper.
 030       */
 031      public function __construct(array $helpers = array())
 032      {
 033          $this->helpers = array();
 034          foreach ($helpers as $alias => $helper) {
 035              $this->set($helper, is_int($alias) ? null : $alias);
 036          }
 037      }
 038   
 039      /**
 040       * Sets a helper.
 041       *
 042       * @param HelperInterface $helper The helper instance
 043       * @param string          $alias  An alias
 044       */
 045      public function set(HelperInterface $helper, $alias = null)
 046      {
 047          $this->helpers[$helper->getName()] = $helper;
 048          if (null !== $alias) {
 049              $this->helpers[$alias] = $helper;
 050          }
 051   
 052          $helper->setHelperSet($this);
 053      }
 054   
 055      /**
 056       * Returns true if the helper if defined.
 057       *
 058       * @param string $name The helper name
 059       *
 060       * @return bool    true if the helper is defined, false otherwise
 061       */
 062      public function has($name)
 063      {
 064          return isset($this->helpers[$name]);
 065      }
 066   
 067      /**
 068       * Gets a helper value.
 069       *
 070       * @param string $name The helper name
 071       *
 072       * @return HelperInterface The helper instance
 073       *
 074       * @throws \InvalidArgumentException if the helper is not defined
 075       */
 076      public function get($name)
 077      {
 078          if (!$this->has($name)) {
 079              throw new \InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name));
 080          }
 081   
 082          return $this->helpers[$name];
 083      }
 084   
 085      /**
 086       * Sets the command associated with this helper set.
 087       *
 088       * @param Command $command A Command instance
 089       */
 090      public function setCommand(Command $command = null)
 091      {
 092          $this->command = $command;
 093      }
 094   
 095      /**
 096       * Gets the command associated with this helper set.
 097       *
 098       * @return Command A Command instance
 099       */
 100      public function getCommand()
 101      {
 102          return $this->command;
 103      }
 104  }
 105