Attach new observer.

@param callback $observer Observer

@return Event
554183
final public function attach($observer)
  {
    if (!in_array($observer, $this->_observers)) {
      array_push($this->_observers, $observer);
    }
    return $this;
  }
760104
protected function trigger ($event)
	{
		$arguments = func_get_args ();
		array_shift ($arguments);

		// Check for events
		if (isset ($this->events[$event]))
		{
			foreach ($this->events[$event] as $call)
			{
				call_user_func_array ($call, $arguments);
			}
		}

		// Notify everyone
		foreach ($this->observing as $observer)
		{
			$observer->update ();
		}
	}
1053445
final public function detach($observer)
  {
    $key = array_search($observer, $this->_observers);
    if ($key !== false) {
      unset($this->_observers[$key]);
    }
    return $this;
  }
1282536
public function unregisterObserver($observer) {
        if (!is_string($observer)) {
            $observer = $observer->getName();
        }
        unset($this->_observers[$observer]);
        return $this;
    }
905392
public function trigger($event = null)
    {
        //argument 1 must be string
        Argument::i()->test(1, 'string', 'null');

        if (is_null($event)) {
            $trace = debug_backtrace();
            $event = $trace[1]['function'];
            if (isset($trace[1]['class']) && trim($trace[1]['class'])) {
                $event = str_replace('\\', '-', $trace[1]['class']).'-'.$event;
            }
        }

        //get the arguments
        $args = func_get_args();
        //shift out the event
        array_shift($args);

        //for each observer
        foreach ($this->observers as $observer) {
            //if this is the same event, call the method, if the method returns false
            if ($event == $observer[0] && call_user_func_array($observer[2], $args) === false) {
                //break out of the loop
                break;
            }
        }

        return $this;
    }
1286138
public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $groups = $this->context->getRequest()->getPost('groups');

        if (isset($groups['api']['fields']['username']['inherit'])
            || isset($groups['api']['fields']['password']['inherit'])
        ) {
            return $this;
        }

        $apiUsername = isset($groups['api']['fields']['username']['value'])
            ? $groups['api']['fields']['username']['value'] : false;
        $apiPassword = isset($groups['api']['fields']['password']['value'])
            ? $groups['api']['fields']['password']['value'] : false;

        $this->validateAccount($apiUsername, $apiPassword);

        return $this;
    }
646895
public function attach(ObserverInterface $observer)
    {
        $observers = $this->getObservers();

        foreach ($observer->getEvents() as $event) {
            $observers[$event][] = $observer;
        }

        $this->setObservers($observers);
    }
774465
protected function removeObserversByEvent(string $event, callable $callback): EventInterface
    {
        //if event isn't set
        if (!isset($this->observers[$event])) {
            //do nothing
            return $this;
        }

        //'foobar' => array(
        foreach ($this->observers[$event] as $i => $observer) {
            //0 => callback
            if ($observer['observer']->assertEquals($callback)) {
                unset($this->observers[$event][$i]);
            }
        }

        return $this;
    }
1023359
public function attach(ObserverInterface $observer): void
    {
        $key = spl_object_hash($observer);

        if ( array_key_exists($key, $this->observers) ) {
            throw new ObservatoryException(
                'Provided observer already known, hash: '.$key
            );
        }

        $this->observers[$key] = $observer;
    }
1126459
public function execute(Observer $observer)
    {
        /** @var Customer $customer */
        $customer = $observer->getEvent()->getCustomer();

        try {
            $this->customerEventHandler->store(
                $customer->getId(),
                $customer->getWebsiteId(),
                $customer->getStoreId()
            );
        } catch (\Exception $e) {
            $this->logger->warning('Emartech\\Emarsys\\Observers\\CustomerAccountObserver: ' . $e->getMessage());
        }
    }
1006131
public void addObserver(OutputObserver observer)
    {
        if (_observers==null)
            _observers=new ArrayList(4);
        _observers.add(observer);
        _observers.add(null);
    }
594327
public function attach($event, $callback, $priority = 0)
    {
        if (!isset($this->eventListeners[$event])) {
            $this->clearListeners($event);
        }

        $this->eventListeners[$event]->insert($callback, $priority);

        return true;
    }
1355559
public function on($event, $callback) {
		if (!is_callable($callback)) {
			throw new ListenException(var_export($callback, true) . " is not callback");
		}
		$this->callback[$event] = $callback;
	}
553262
public function attach(string $event, callable $callback, int $priority = 0){
        if(!isset($this->listeners[$event])){
            $this->listeners[$event] = new Performer();
        }
        $this->listeners[$event]->add($callback, $priority);
    }
1125667
public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $customer = $observer->getEvent()->getCustomer();
        $websiteId  = $customer->getWebsiteId();
        $storeId = $customer->getStoreId();

        //check if enabled
        if (!$this->helper->isEnabled($websiteId)) {
            return $this;
        }

        $email      = $customer->getEmail();
        $customerId = $customer->getEntityId();
        $subscriber = $this->subscriberFactory->create()
            ->loadByCustomerId($customerId);
        $isSubscribed = $subscriber->isSubscribed();

        $emailBefore = '';

        try {
            // fix for a multiple hit of the observer
            $emailReg = $this->registry->registry($email . '_customer_save');
            if ($emailReg) {
                return $this;
            }
            $this->registry->unregister($email . '_customer_save'); // additional measure
            $this->registry->register($email . '_customer_save', $email);

            $isContactExist = $this->contactFactory->create()
                ->loadByCustomerId($customerId);

            if ($isContactExist->getId()) {
                $emailBefore = $isContactExist->getEmail();
            }

            $emailAddress = empty($emailBefore) ? $email : $emailBefore;

            $contactModel = $this->contactFactory->create()
                ->loadByCustomerEmail($emailAddress, $websiteId);

            //email change detection
            if ($emailBefore && $email != $emailBefore) {
                //Reload contact model up update email
                $contactModel = $this->contactFactory->create()
                    ->loadByCustomerEmail($emailAddress, $websiteId);
                $contactModel->setEmail($email);

                $data = [
                    'emailBefore' => $emailBefore,
                    'email' => $email,
                    'isSubscribed' => $isSubscribed,
                ];
                $this->importerFactory->create()->registerQueue(
                    \Dotdigitalgroup\Email\Model\Importer::IMPORT_TYPE_CONTACT_UPDATE,
                    $data,
                    \Dotdigitalgroup\Email\Model\Importer::MODE_CONTACT_EMAIL_UPDATE,
                    $websiteId
                );
            } elseif (!$emailBefore) {
                //for new contacts update email
                $contactModel->setEmail($email);
            }
            $contactModel->setEmailImported(\Dotdigitalgroup\Email\Model\Contact::EMAIL_CONTACT_NOT_IMPORTED)
                ->setStoreId($storeId)
                ->setCustomerId($customerId);
            $this->contactResource->save($contactModel);
        } catch (\Exception $e) {
            $this->helper->debug((string)$e, []);
        }

        return $this;
    }
382539
function(observer, skipUpdate) {
    this.observers.add(observer);
    if (!skipUpdate) {
      observer.forceUpdateNextSync = true;
      observer.sync();
    }
  }
422503
public function controllerActionLayoutLoadBefore(Varien_Event_Observer $observer)
    {
        if (!$this->_getHelper()->isActive()) {
            return;
        }
        
        $updateModel = $observer->getLayout()->getUpdate();
        $handles = $updateModel->getHandles();
        $allowedEsi = $this->_getHelper()->getIsEsiAllowed();
        foreach ($handles as $handle) {
            if ($handle == 'customer_logged_in' 
                && !$this->_getHelper()->getIsInternal()) {
                $updateModel->removeHandle($handle);
                // Emulate always guest session
                $updateModel->addHandle('customer_logged_out');
            }
            
            if ($handle == 'default' && !$this->_getHelper()->getIsInternal()) {
                $updateModel->addHandle('default_varnish');
            }
            
            if ($allowedEsi && strtolower($handle) === $handle) {
                // Add handle only if handle is not starting from UPPERCASE code
                $updateModel->addHandle($handle . '_esi');
            }
        }
    }