@param EventSubscriberInterface $subscriber

@return $this
160096
public function removeSubscriber(EventSubscriberInterface $subscriber)
    {
        unset($this->subscribers[array_search($subscriber, $this->subscribers, true)]);
        $this->subscribers = empty($this->subscribers) ? [] : array_values($this->subscribers);

        return $this;
    }
901191
public function saveSubscriber(SubscriberInterface $subscriber)
    {
        $token = $this->getToken();

        $groups = $subscriber->getGroups()->getValues();

        $data = [
            'postdata' => [
                [
                    'email' => $subscriber->getEmail()
                ]
            ]
        ];

        $event = new CleverReachEvent($subscriber, $data);
        $this->eventDispatcher->dispatch(NewsletterEvents::EVENT_CLEVERREACH_PRE_SEND, $event);
        if($event->getDataArray()){
            $data = $event->getDataArray();
        }

        /** @var Group $group */
        foreach ($groups as $group) {
            if ($this->exists($subscriber->getEmail(), $group)) {
                continue;
            }

            $groupId = $this->mapGroup($group);

            $res = $this->guzzleClient->request('POST', 'groups.json/' . $groupId . '/receivers/insert' . '?token=' . $token, [
                'json' => $data
            ]);

            $response = $res->getBody()->getContents();

            if (json_decode($response)[0]->status !== 'insert success') {
                throw new InsertException(
                    sprintf('Insertion in group "%s" with id "%s" failed.', $group->getName(), $groupId)
                );
            }
        }
    }
633696
public function add_subscriber( EventSubscriber $subscriber ) {

		foreach ( $subscriber->get_subscribed_events() as $event => $params ) {

			if ( is_string( $params ) ) {
				$this->add_listener( $event, array( $subscriber, $params ) );
			} elseif ( is_array( $params ) && isset( $params[0] ) ) {

				$method        = $params[0];
				$priority      = isset( $params[1] ) ? $params[1] : self::PRIORITY;
				$accepted_args = isset( $params[2] ) ? $params[2] : self::ACCEPTED;

				$this->add_listener( $event, array( $subscriber, $method ), $priority, $accepted_args );
			} else {
				throw new \InvalidArgumentException( 'Invalid return format from EventSubscriber.' );
			}
		}

		return $this;
	}
736715
public synchronized int removeSubscriber(String eventName, IGenericEvent<T> subscriber) {
        List<IGenericEvent<T>> subscribers = getSubscribers(eventName, false);
        
        if (subscribers != null) {
            subscribers.remove(subscriber);
            
            if (subscribers.isEmpty()) {
                subscriptions.remove(eventName);
            }
            
            return subscribers.size();
        }
        
        return -1;
    }
60729
public function onPending(SubscriberEvent $event)
    {
        $this->listRepository->pending(
            $event->getListId(),
            $event->getSubscriber()
        );
    }
465642
public function onChangeEmail(SubscriberEvent $event)
    {
        $this->listRepository->changeEmailAddress(
            $event->getListId(),
            $event->getSubscriber(),
            $event->getOldEmail()
        );
    }
924330
public function reportSubscriberEvents(Subscriber $subscriber, $event_type = NULL)
		{
			$form_data = array(
				'subscriber_id' => $subscriber->getSubscriberId(),
				'event_type' => $event_type,

			);
			$xml = $this->call('rpt_subscriber_events', $form_data);

			$reports = array();

			foreach ($xml->Data as $reportItem) {
				$report = new Report;
				$report
					->setEventName((string)$reportItem->event)
					->setEventId((int)$reportItem->event_id)
					->setListName((string)$reportItem->list)
					->setListId((int)$reportItem->list_id)
					->setDate(date_create_from_format('m/d/y h:i A', $reportItem->date));
				$reports[] = $report;
			}

			return $reports;
		}
548126
public function subscribe($subscriber)
    {
        if (is_object($subscriber)) {
            $subscriber->subscribe($this);
            return;
        }
        $this->subscribe(new $subscriber);
    }
623899
public function onUnsubscribe(SubscriberEvent $event)
    {
        $this->listRepository->unsubscribe(
            $event->getListId(),
            $event->getSubscriber()
        );
    }
734382
public function addSubscriber(SubscriberInterface $instance) {

		// make sure that an already registered object is removed before re-registering
		
		$this->removeSubscriber($instance);

		// register object hash

		$this->registeredHashes[] = spl_object_hash($instance);

		// parameters contain at least a method name; additionally a priority can be added
		
		foreach($instance::getEventsToSubscribe() as $eventName => $parameters) {

			$parameters	= (array) $parameters;
			$methodName	= array_shift($parameters); 

			if(count($parameters)) {
				$priority = (int) $parameters[0];
			}
			else {
				$priority = 0;
			}

			if(!isset($this->registry[$eventName]) || !isset($this->registry[$eventName][$priority])) {
				$this->registry[$eventName][$priority] = [];
			}

			$this->registry[$eventName][$priority][] = [$instance, $methodName];

			// force re-sort upon next dispatch

			unset ($this->sortedRegistry[$eventName]);

		}
		
	}
639401
public function setEventManager(EventManagerInterface $eventManager)
    {
        $eventManager->setIdentifiers(
            array(
                __CLASS__,
                get_called_class(),
                $this->getName()
            )
        );
        $this->_events = $eventManager;
        return $this;
    }
1184499
public function setEventDispatcher(EventDispatcherInterface $eventDispatcher)
    {
        if ($this->handler) {
            throw new AlreadyBuildedException('The handler already builded.');
        }

        $this->eventDispatcher = $eventDispatcher;

        return $this;
    }
406993
public function addSubscriber(SubscriberInterface $subscriber)
    {
        foreach ($subscriber->getSubscriberEvents() as $subscriberEvent => $params) {
            if (is_string($params)) {
                $this->addListener($subscriberEvent, array($subscriber, $params));
            }

            if (is_array($params)) {
                foreach ($params as $param) {
                    $this->addListener($subscriberEvent, array($subscriber, $param));
                }
            }
        }
    }
1161353
public function onSubscribe(SubscriberEvent $event)
    {
        $this->listRepository->subscribe(
            $event->getListId(),
            $event->getSubscriber()
        );
    }
545118
public static void register(Class<? extends Event> eventClass, Subscriber subscriber) {
        CopyOnWriteArraySet<Subscriber> set = SUBSCRIBER_MAP.get(eventClass);
        if (set == null) {
            set = new CopyOnWriteArraySet<Subscriber>();
            CopyOnWriteArraySet<Subscriber> old = SUBSCRIBER_MAP.putIfAbsent(eventClass, set);
            if (old != null) {
                set = old;
            }
        }
        set.add(subscriber);
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Register subscriber: {} of event: {}.", subscriber, eventClass);
        }
    }
1172392
public function removeEventSubscriber(EventSubscriberInterface $subscriber)
    {
        if (!$this->dispatcher) {
            $this->dispatcher = new EventDispatcher();
        }

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

        return $this;
    }
183029
public function removeEventDispatcher($subscriber)
    {
        if (! ($subscriber instanceof AnEventSubscriberInterface)) {
            $subscriber = $this->getEventSubscriber($subscriber, $config);
        }
        
        $this->_event_dispatcher->removeEventSubscriber($subscriber);
        return $this->getMixer();
    }