Server IP : 127.0.0.2 / Your IP : 3.137.152.81 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/vendor/guzzlehttp/guzzle/src/Event/ |
Upload File : |
<?php namespace GuzzleHttp\Event; /** * Guzzle event emitter. * * Some of this class is based on the Symfony EventDispatcher component, which * ships with the following license: * * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. * * @link https://github.com/symfony/symfony/tree/master/src/Symfony/Component/EventDispatcher */ class Emitter implements EmitterInterface { /** @var array */ private $listeners = []; /** @var array */ private $sorted = []; public function on($eventName, callable $listener, $priority = 0) { if ($priority === 'first') { $priority = isset($this->listeners[$eventName]) ? max(array_keys($this->listeners[$eventName])) + 1 : 1; } elseif ($priority === 'last') { $priority = isset($this->listeners[$eventName]) ? min(array_keys($this->listeners[$eventName])) - 1 : -1; } $this->listeners[$eventName][$priority][] = $listener; unset($this->sorted[$eventName]); } public function once($eventName, callable $listener, $priority = 0) { $onceListener = function ( EventInterface $event ) use (&$onceListener, $eventName, $listener, $priority) { $this->removeListener($eventName, $onceListener); $listener($event, $eventName); }; $this->on($eventName, $onceListener, $priority); } public function removeListener($eventName, callable $listener) { if (empty($this->listeners[$eventName])) { return; } foreach ($this->listeners[$eventName] as $priority => $listeners) { if (false !== ($key = array_search($listener, $listeners, true))) { unset( $this->listeners[$eventName][$priority][$key], $this->sorted[$eventName] ); } } } public function listeners($eventName = null) { // Return all events in a sorted priority order if ($eventName === null) { foreach (array_keys($this->listeners) as $eventName) { if (empty($this->sorted[$eventName])) { $this->listeners($eventName); } } return $this->sorted; } // Return the listeners for a specific event, sorted in priority order if (empty($this->sorted[$eventName])) { $this->sorted[$eventName] = []; if (isset($this->listeners[$eventName])) { krsort($this->listeners[$eventName], SORT_NUMERIC); foreach ($this->listeners[$eventName] as $listeners) { foreach ($listeners as $listener) { $this->sorted[$eventName][] = $listener; } } } } return $this->sorted[$eventName]; } public function hasListeners($eventName) { return !empty($this->listeners[$eventName]); } public function emit($eventName, EventInterface $event) { if (isset($this->listeners[$eventName])) { foreach ($this->listeners($eventName) as $listener) { $listener($event, $eventName); if ($event->isPropagationStopped()) { break; } } } return $event; } public function attach(SubscriberInterface $subscriber) { foreach ($subscriber->getEvents() as $eventName => $listeners) { if (is_array($listeners[0])) { foreach ($listeners as $listener) { $this->on( $eventName, [$subscriber, $listener[0]], isset($listener[1]) ? $listener[1] : 0 ); } } else { $this->on( $eventName, [$subscriber, $listeners[0]], isset($listeners[1]) ? $listeners[1] : 0 ); } } } public function detach(SubscriberInterface $subscriber) { foreach ($subscriber->getEvents() as $eventName => $listener) { $this->removeListener($eventName, [$subscriber, $listener[0]]); } } }