Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

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

AttributeFilterCollection.php

Zuletzt modifiziert: 01.05.2026, 11:28 - Dateigröße: 2.40 KiB


 001  <?php
 002   
 003  /**
 004  * @package   s9e\TextFormatter
 005  * @copyright Copyright (c) 2010-2022 The s9e authors
 006  * @license   http://www.opensource.org/licenses/mit-license.php The MIT License
 007  */
 008  namespace s9e\TextFormatter\Configurator\Collections;
 009   
 010  use InvalidArgumentException;
 011  use s9e\TextFormatter\Configurator\Items\AttributeFilter;
 012   
 013  class AttributeFilterCollection extends NormalizedCollection
 014  {
 015      /**
 016      * Return a value from this collection
 017      *
 018      * @param  string $key
 019      * @return \s9e\TextFormatter\Configurator\Items\ProgrammableCallback
 020      */
 021      public function get($key)
 022      {
 023          $key = $this->normalizeKey($key);
 024   
 025          if (!$this->exists($key))
 026          {
 027              if ($key[0] === '#')
 028              {
 029                  $this->set($key, self::getDefaultFilter(substr($key, 1)));
 030              }
 031              else
 032              {
 033                  $this->set($key, new AttributeFilter($key));
 034              }
 035          }
 036   
 037          // Get the filter from the collection
 038          $filter = parent::get($key);
 039   
 040          // Clone it to preserve the original instance
 041          $filter = clone $filter;
 042   
 043          return $filter;
 044      }
 045   
 046      /**
 047      * Get an instance of the default filter for given name
 048      *
 049      * @param  string          $filterName Filter name, e.g. "int" or "color"
 050      * @return AttributeFilter
 051      */
 052      public static function getDefaultFilter($filterName)
 053      {
 054          $filterName = ucfirst(strtolower($filterName));
 055          $className  = 's9e\\TextFormatter\\Configurator\\Items\\AttributeFilters\\' . $filterName . 'Filter';
 056   
 057          if (!class_exists($className))
 058          {
 059              throw new InvalidArgumentException("Unknown attribute filter '" . $filterName . "'");
 060          }
 061   
 062          return new $className;
 063      }
 064   
 065      /**
 066      * Normalize the name of an attribute filter
 067      *
 068      * @param  string $key
 069      * @return string
 070      */
 071      public function normalizeKey($key)
 072      {
 073          // Built-in/custom filter, normalized to lowercase
 074          if (preg_match('/^#[a-z_0-9]+$/Di', $key))
 075          {
 076              return strtolower($key);
 077          }
 078   
 079          // Valid callback
 080          if (is_string($key) && is_callable($key))
 081          {
 082              return $key;
 083          }
 084   
 085          throw new InvalidArgumentException("Invalid filter name '" . $key . "'");
 086      }
 087   
 088      /**
 089      * Normalize a value to an instance of AttributeFilter
 090      *
 091      * @param  callable|AttributeFilter $value
 092      * @return AttributeFilter
 093      */
 094      public function normalizeValue($value)
 095      {
 096          if ($value instanceof AttributeFilter)
 097          {
 098              return $value;
 099          }
 100   
 101          if (is_callable($value))
 102          {
 103              return new AttributeFilter($value);
 104          }
 105   
 106          throw new InvalidArgumentException('Argument 1 passed to ' . __METHOD__ . ' must be a valid callback or an instance of s9e\\TextFormatter\\Configurator\\Items\\AttributeFilter');
 107      }
 108  }