@param string   $eventName
@param callable $subscriber

@return self
767661
public function unSubscribe(string $eventName, callable $subscriber): self
    {
        if (($subscriber instanceof Closure) === false &&
            ($staticMethod = $this->parseStaticMethod($subscriber)) !== null
        ) {
            $subscriber = $this->getUnifiedStaticMethodRepresentation($staticMethod);
        }

        $eventSubscribers = $this->getEventSubscribers($eventName);
        $eventSubscribers = array_filter($eventSubscribers, function ($curSubscriber) use ($subscriber) {
            return $curSubscriber !== $subscriber;
        });

        return $this->setEventSubscribers($eventName, $eventSubscribers);
    }
639465
public function addListener(string $eventName, $listener) : void
    {
        $this->dispatcher->addListener($eventName, $listener);
    }
651591
protected function offAll(string $eventName): self
    {
        $hasEvent = $this->listeners[$eventName] ?? false;
        if ($hasEvent) {
            unset($this->listeners[$eventName], $this->sorted[$eventName]);
        }

        return $this;
    }
415008
public function dispatch($eventName, Event $event)
    {
        if (!$this->hasListeners($eventName)) {
            return $event;
        }

        // setting event name
        $event->setName($eventName);

        // execute all callbacks for a event given
        foreach ($this->getListeners($event->getName()) as $listener) {
            call_user_func($listener, $event);

            if ($event->isPropagationStopped()) {
                break;
            }
        }

        return $event;
    }
142238
protected function invokeSubscriberByInstance($subscriber, IEvent $event) {
        if (is_object($subscriber) && method_exists($subscriber, 'handle')) {
            $this->invokeSubscriber($subscriber, $event);

            return true;
        }

        return false;
    }
612021
public function isSubscribed(AnEventSubscriberInterface $subscriber)
    {
        $handle = $subscriber->getHandle();
        return isset($this->_subscribers[$handle]);
    }
232644
public function dispatchUntil($eventName, Event $event)
    {
        // skip dispatching because event is already dispatched
        if ($event->isProcessed()) {
            return $event;
        }

        // skip dispatching because event hasn't listeners
        if (!$this->hasListeners($eventName)) {
            return $event;
        }

        $event->setName($eventName);

        foreach ($this->getListeners($event->getName()) as $listener) {
            if (call_user_func($listener, $event)) {
                $event->setProcessed(true);
                break;
            }
        }

        return $event;
    }
1310663
public function dispatch($eventName, Event $event = null)
    {
        if (null === $event) {
            $event = new Event();
        }

        $event->setDispatcher($this);
        $event->setName($eventName);

        if (!isset($this->listeners[$eventName])) {
            return $event;
        }

        $this->doDispatch($this->getListeners($eventName), $eventName, $event);

        return $event;
    }
625373
public function attachSubscriber(Subscriber $subscriber)
	{
		$listeners = $subscriber->getRegisteredEvents();
		foreach($listeners as $id => $listener) {
			EventManager::listenTo($id, array($subscriber, $listener));
		}
	}
1301737
public void subscribeToEvent(final EventListener eventListener, final Class<? extends AbstractTaskEvent> eventType) {

		synchronized (this.subscriptions) {

			List<EventListener> subscribers = this.subscriptions.get(eventType);
			if (subscribers == null) {
				subscribers = new ArrayList<EventListener>();
				this.subscriptions.put(eventType, subscribers);
			}
			subscribers.add(eventListener);
		}

	}
88294
public function publish(Event $event)
    {
        foreach ($this->subscribers as $subscriber) {
            if ($subscriber->isSubscribedTo($event)) {
                $subscriber->handle($event);
            }
        }

        return $this;
    }
510639
public function dispatchEvent(String $eventId, $subscriber=null)
	{
		if (isset(EventManager::$listeners[$eventId])) {
			foreach(EventManager::$listeners[$eventId] as $listener) {
				call_user_func_array($listener, [$subscriber]);
			}
		}
	}
1172392
public function removeEventSubscriber(EventSubscriberInterface $subscriber)
    {
        if (!$this->dispatcher) {
            $this->dispatcher = new EventDispatcher();
        }

        $this->dispatcher->removeSubscriber($subscriber);

        return $this;
    }
1041387
protected function triggerEvent($eventName, NodeInterface $node = null)
    {
        if (isset($this->activeEvents[$eventName])) {
            $this->dispatcher->dispatch($eventName, $this->sharedEvent->setNode($node));
        }

        return $this;
    }
1279109
public void subscribe(Class<? extends Event> eventType, Class<? extends Subscriber> subscriberType) {
        if (!subscriptionMap.containsKey(eventType)) {
            subscriptionMap.put(eventType, new ArrayList<>());
        }
        final ArrayList<Class<? extends Subscriber>> subscribers = subscriptionMap.get(eventType);
        if (!subscribers.contains(subscriberType)) {
            subscribers.add(subscriberType);
        }
    }
755149
public function it_should_have_listener_after_adding_service_subscriber(MockServiceSubscriber $sub)
    {
        $events = [
            'test1' => [
                [
                    [
                        'containerID1',
                        'method1'
                    ],
                    [
                        'containerID1',
                        'method2'
                    ]
                ]
            ],
            'test2' => [
                [
                    [
                        'containerID1',
                        'method1'
                    ],
                    [
                        'containerID1',
                        'method2'
                    ]
                ]
            ]
        ];
        $this->getServiceListeners()
             ->shouldHaveCount(0);
        $sub->getServiceSubscribedEvents()
            ->willReturn($events);
        $this->addServiceSubscriber($sub);
        $this->getServiceListeners()
             ->shouldHaveCount(2);
        $this->getServiceListeners()
             ->shouldHaveKey('test1');
        $this->getServiceListeners()
             ->shouldHaveKey('test2');
    }
573535
public function setSubscriber($subscriber)
    {
        $this->_subscriber = $subscriber;

        if ($subscriber->persisted()) {
            $this->actorId = $this->_subscriber->id;
        } else {
            $this->set('actorId', PHP_INT_MAX);
        }

        $this->getRepository()->getSpace()->setSaveOrder($this, $this->_subscriber);

        return $this;
    }