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. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
FilterChain.php
001 <?php
002 /**
003 * Zend Framework (http://framework.zend.com/)
004 *
005 * @link http://github.com/zendframework/zf2 for the canonical source repository
006 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
007 * @license http://framework.zend.com/license/new-bsd New BSD License
008 */
009
010 namespace Zend\EventManager;
011
012 use Zend\Stdlib\CallbackHandler;
013
014 /**
015 * FilterChain: intercepting filter manager
016 */
017 class FilterChain implements Filter\FilterInterface
018 {
019 /**
020 * @var Filter\FilterIterator All filters
021 */
022 protected $filters;
023
024 /**
025 * Constructor
026 *
027 * Initializes Filter\FilterIterator in which filters will be aggregated
028 */
029 public function __construct()
030 {
031 $this->filters = new Filter\FilterIterator();
032 }
033
034 /**
035 * Apply the filters
036 *
037 * Begins iteration of the filters.
038 *
039 * @param mixed $context Object under observation
040 * @param mixed $argv Associative array of arguments
041 * @return mixed
042 */
043 public function run($context, array $argv = array())
044 {
045 $chain = clone $this->getFilters();
046
047 if ($chain->isEmpty()) {
048 return;
049 }
050
051 $next = $chain->extract();
052 if (!$next instanceof CallbackHandler) {
053 return;
054 }
055
056 return call_user_func($next->getCallback(), $context, $argv, $chain);
057 }
058
059 /**
060 * Connect a filter to the chain
061 *
062 * @param callable $callback PHP Callback
063 * @param int $priority Priority in the queue at which to execute; defaults to 1 (higher numbers == higher priority)
064 * @return CallbackHandler (to allow later unsubscribe)
065 * @throws Exception\InvalidCallbackException
066 */
067 public function attach($callback, $priority = 1)
068 {
069 if (empty($callback)) {
070 throw new Exception\InvalidCallbackException('No callback provided');
071 }
072 $filter = new CallbackHandler($callback, array('priority' => $priority));
073 $this->filters->insert($filter, $priority);
074 return $filter;
075 }
076
077 /**
078 * Detach a filter from the chain
079 *
080 * @param CallbackHandler $filter
081 * @return bool Returns true if filter found and unsubscribed; returns false otherwise
082 */
083 public function detach(CallbackHandler $filter)
084 {
085 return $this->filters->remove($filter);
086 }
087
088 /**
089 * Retrieve all filters
090 *
091 * @return Filter\FilterIterator
092 */
093 public function getFilters()
094 {
095 return $this->filters;
096 }
097
098 /**
099 * Clear all filters
100 *
101 * @return void
102 */
103 public function clearFilters()
104 {
105 $this->filters = new Filter\FilterIterator();
106 }
107
108 /**
109 * Return current responses
110 *
111 * Only available while the chain is still being iterated. Returns the
112 * current ResponseCollection.
113 *
114 * @return null|ResponseCollection
115 */
116 public function getResponses()
117 {
118 return;
119 }
120 }
121