__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
/**
* Part of the Joomla Framework Event Package
*
* @copyright Copyright (C) 2005 - 2021 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Event;
/**
* A class containing an inner listeners priority queue that can be iterated multiple times.
*
* @since 1.0
* @internal
*/
final class ListenersPriorityQueue implements \IteratorAggregate, \Countable
{
/**
* The listeners for an event.
*
* @var array
* @since 2.0.0
*/
private $listeners = [];
/**
* Add a listener with the given priority only if not already present.
*
* @param callable $callback A callable function acting as an event listener.
* @param integer $priority The listener priority.
*
* @return $this
*
* @since 1.0
*/
public function add(callable $callback, int $priority): self
{
$this->listeners[$priority][] = $callback;
return $this;
}
/**
* Remove a listener from the queue.
*
* @param callable $callback A callable function acting as an event listener.
*
* @return $this
*
* @since 1.0
*/
public function remove(callable $callback): self
{
foreach ($this->listeners as $priority => $listeners) {
if (($key = array_search($callback, $listeners, true)) !== false) {
unset($this->listeners[$priority][$key]);
}
}
return $this;
}
/**
* Tell if the listener exists in the queue.
*
* @param callable $callback A callable function acting as an event listener.
*
* @return boolean True if it exists, false otherwise.
*
* @since 1.0
*/
public function has(callable $callback): bool
{
foreach ($this->listeners as $priority => $listeners) {
if (($key = array_search($callback, $listeners, true)) !== false) {
return true;
}
}
return false;
}
/**
* Get the priority of the given listener.
*
* @param callable $callback A callable function acting as an event listener.
* @param mixed $default The default value to return if the listener doesn't exist.
*
* @return mixed The listener priority if it exists or the specified default value
*
* @since 1.0
*/
public function getPriority(callable $callback, $default = null)
{
foreach ($this->listeners as $priority => $listeners) {
if (($key = array_search($callback, $listeners, true)) !== false) {
return $priority;
}
}
return $default;
}
/**
* Get all listeners contained in this queue, sorted according to their priority.
*
* @return callable[] An array of listeners.
*
* @since 1.0
*/
public function getAll(): array
{
if (empty($this->listeners)) {
return [];
}
krsort($this->listeners);
return \call_user_func_array('array_merge', $this->listeners);
}
/**
* Get the priority queue.
*
* @return \ArrayIterator
*
* @since 1.0
*/
#[\ReturnTypeWillChange]
public function getIterator()
{
return new \ArrayIterator($this->getAll());
}
/**
* Count the number of listeners in the queue.
*
* @return integer The number of listeners in the queue.
*
* @since 1.0
*/
#[\ReturnTypeWillChange]
public function count()
{
$count = 0;
foreach ($this->listeners as $priority) {
$count += \count($priority);
}
return $count;
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| Command | Folder | 0775 |
|
|
| AbstractEvent.php | File | 4.87 KB | 0664 |
|
| Dispatcher.php | File | 13.57 KB | 0664 |
|
| DispatcherAwareInterface.php | File | 686 B | 0664 |
|
| DispatcherAwareTrait.php | File | 1.22 KB | 0664 |
|
| DispatcherInterface.php | File | 3.67 KB | 0664 |
|
| Event.php | File | 3.1 KB | 0664 |
|
| EventImmutable.php | File | 2.38 KB | 0664 |
|
| EventInterface.php | File | 1.23 KB | 0664 |
|
| LazyServiceEventListener.php | File | 3.65 KB | 0664 |
|
| ListenersPriorityQueue.php | File | 3.73 KB | 0664 |
|
| Priority.php | File | 1.69 KB | 0664 |
|
| SubscriberInterface.php | File | 895 B | 0664 |
|