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

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

FilterChain.php

Zuletzt modifiziert: 02.04.2025, 15:04 - Dateigröße: 2.09 KiB


01  <?php
02   
03  /**
04  * @package   s9e\TextFormatter
05  * @copyright Copyright (c) 2010-2022 The s9e authors
06  * @license   http://www.opensource.org/licenses/mit-license.php The MIT License
07  */
08  namespace s9e\TextFormatter\Configurator\Collections;
09   
10  use InvalidArgumentException;
11  use s9e\TextFormatter\Configurator\Helpers\FilterHelper;
12  use s9e\TextFormatter\Configurator\Items\Filter;
13  use s9e\TextFormatter\Configurator\Items\ProgrammableCallback;
14   
15  abstract class FilterChain extends NormalizedList
16  {
17      /**
18      * Get the name of the filter class
19      *
20      * @return string
21      */
22      abstract protected function getFilterClassName();
23   
24      /**
25      * Test whether this filter chain contains given callback
26      *
27      * @param  callable $callback
28      * @return bool
29      */
30      public function containsCallback(callable $callback)
31      {
32          // Normalize the callback
33          $pc = new ProgrammableCallback($callback);
34          $callback = $pc->getCallback();
35          foreach ($this->items as $filter)
36          {
37              if ($callback === $filter->getCallback())
38              {
39                  return true;
40              }
41          }
42   
43          return false;
44      }
45   
46      /**
47      * Normalize a value into an TagFilter instance
48      *
49      * @param  mixed  $value Either a valid callback or an instance of TagFilter
50      * @return Filter        Normalized filter
51      */
52      public function normalizeValue($value)
53      {
54          if (is_string($value) && strpos($value, '(') !== false)
55          {
56              return $this->createFilter($value);
57          }
58   
59          $className = $this->getFilterClassName();
60          if ($value instanceof $className)
61          {
62              return $value;
63          }
64   
65          if (!is_callable($value))
66          {
67              throw new InvalidArgumentException('Filter ' . var_export($value, true) . ' is neither callable nor an instance of ' . $className);
68          }
69   
70          return new $className($value);
71      }
72   
73      /**
74      * Create and return a filter
75      *
76      * @param  string $filterString
77      * @return Filter
78      */
79      protected function createFilter($filterString)
80      {
81          $config = FilterHelper::parse($filterString);
82          $filter = $this->normalizeValue($config['filter']);
83          if (isset($config['params']))
84          {
85              $filter->resetParameters();
86              foreach ($config['params'] as [$type, $value])
87              {
88                  $methodName = 'addParameterBy' . $type;
89                  $filter->$methodName($value);
90              }
91          }
92   
93          return $filter;
94      }
95  }