Attach $this to the event manager if not yet

@access protected
@since  2.1.5
166160
protected function attachSelfToEventManager()
    {
        if (!$this->listener_attached) {
            if ($this->event_manager instanceof ListenerAwareInterface &&
                $this instanceof ListenerInterface
            ) {
                $this->event_manager->attachListener($this);
            }
            $this->listener_attached = true;
        }
    }
1315535
public function attachEvents()
    {
        $appEvents = $this->container->get('event')->getAppEvents();

        if (!empty($appEvents)) {
            foreach ($appEvents as $event => $namespace) {
                // attach all before and after event to handler
                $this->container->get('event')->attach("$event", $namespace);
            }
        }
    }
1345696
function() {
        var html = this.root.getHtml(),
            el = this.getEl();
        el.innerHTML = html;
        if (!this._hasEvents) {
            Event.on(el, 'click', this._onClickEvent, this, true);
            Event.on(el, 'dblclick', this._onDblClickEvent, this, true);
            Event.on(el, 'mouseover', this._onMouseOverEvent, this, true);
            Event.on(el, 'mouseout', this._onMouseOutEvent, this, true);
            Event.on(el, 'keydown', this._onKeyDownEvent, this, true);
        }
        this._hasEvents = true;
    }
621213
protected function initEntityEvents()
    {
        $this->on(static::EVENT_INIT, [$this, 'onInitCache']);
        $this->attachInitGUIDEvent(static::$eventNewRecordCreated);
        $this->attachInitIDEvent(static::$eventNewRecordCreated);
        $this->attachInitIPEvent(static::$eventNewRecordCreated);
        if ($this->isNewRecord) {
            $this->trigger(static::$eventNewRecordCreated);
        }
        $this->on(static::EVENT_AFTER_FIND, [$this, 'onRemoveExpired']);
    }
803997
public function targetId(): self
    {
        $this->set('target', 'id');

        $this->addBeforeRender(function () {
            $value = (string) $this->get('value');

            if (! ctype_digit($value)) {
                return;
            }

            /** @var Attachment $attach */
            $attach = Dashboard::model(Attachment::class);

            $url = optional($attach::find($value))->url();

            $this->set('url', $url);
        });

        return $this;
    }
570148
function () {
			this.allCheckbox = this.$('#toggle-all')[0];
			this.$input = this.$('#new-todo');
			this.$footer = this.$('#footer');
			this.$main = this.$('#main');
			this.$todoList = this.$('#todo-list');

			this.listenTo(this.collection, 'add', this.addOne);
			this.listenTo(this.collection, 'reset', this.addAll);
			this.listenTo(this.collection, 'change:completed', this.filterOne);
			this.listenTo(this.collection, 'filter', this.filterAll);
			this.listenTo(this.collection, 'all', this.render);

			this.collection.fetch();
		}
553235
protected function ensureEvents()
	{
		if ($this->_events === null) {
			$this->_events = [];
			if (method_exists($this, 'events')) {
			    if ($events = $this->events()) foreach ($events as $name => $handler) {
					$this->on($name, $handler);
				}
			}
		}
	}
269205
protected function __init()
    {
        $events = $this->event();

        // --- How to resolve requested module --------------------------------\
        // --------------------------------------------------------------------\
        ## resolve to module by looking on ModuleName\Module class
        ## also set options on array modules, like ['module'=>$opts]
        $events->on(
            ModuleManagerEvents\EventModuleResolve::EVENT_NAME
            , new ModuleManager\Events\ModuleResolve\ListenerResolverDefault
            , 100
        );

        $events->on(
            ModuleManagerEvents\EventModuleResolve::EVENT_NAME
            , new ModuleManager\Events\ModuleResolve\ListenerResolverDirectory
            , 90
        );

        // --- Features Call Immanently after resolve module object -----------\
        // --------------------------------------------------------------------\
        $events->on(
            ModuleManagerEvents\EventModuleInitialize::EVENT_NAME
            , new ModuleManager\Events\ModuleInitialize\ListenerInitInitialization
            , 1000
        );

        $events->on(
            ModuleManagerEvents\EventModuleInitialize::EVENT_NAME
            , new ModuleManager\Events\ModuleInitialize\ListenerInitServices
            , 900
        );

        ## register modules services and actions
        $events->on(
            ModuleManagerEvents\EventModuleInitialize::EVENT_NAME
            , new ModuleManager\Events\ModuleInitialize\ListenerInitNestedContainer
        );


        // --- Features Call After Whole Modules Initialized        -----------\
        // --------------------------------------------------------------------\
        // Event Param: $module_manager

        # Register Actions
        #
        // Note: Actions do not access to Initialized Configs...
        //       actions on registration just must register itself and no need any instantiate
        $events->on(
            EventHeapOfModuleManager::EVENT_MODULES_POSTLOAD
            , new ModuleManager\Events\ModulesPostLoad\ListenerRegisterActions
            , -100
        );

        # Instantiate Merged Config instance() services
        $events->on(
            EventHeapOfModuleManager::EVENT_MODULES_POSTLOAD
            , new ModuleManager\Events\ModulesPostLoad\ListenerInstantiateMergedConfig
            , -500
        );

        # Resolve registered services to module
        $events->on(
            EventHeapOfModuleManager::EVENT_MODULES_POSTLOAD
            , new ModuleManager\Events\ModulesPostLoad\ListenerGrabRegisteredServices
            , -1000
        );

        ## attach application events listener
        $events->on(
            EventHeapOfModuleManager::EVENT_MODULES_POSTLOAD
            , new ModuleManager\Events\ModuleInitialize\ListenerInitSapiEvents
            , -10000
        );
    }
884849
public function bind($eventName, $callback, $mode = EventsHandlerInterface::BINDING_MODE_LAST)
    {
        if ($eventsHandler = $this->getEventsHandler()) {
            $eventsHandler->bind($eventName, $callback, $mode);
        }
    }
1008884
function on(el, eventName, callback) {
  if (el.addEventListener) {
    el.addEventListener(eventName, callback, false);
  }
  else if (el.attachEvent) {
    el.attachEvent('on'+eventName, function(e) {
      callback.call(el, e || window.event);
    });
  }
}
329892
public static function initEvent()
    {
        if (!self::$supported) {
            return;
        }
        self::updateConfig();
        self::$fd = eio_get_event_stream();
        self::$ev = EventLoop::$instance->event(self::$fd,
            \Event::READ | \Event::PERSIST,
            function ($fd, $events, $arg) {
                while (eio_nreqs()) {
                    eio_poll();
                }
            }
        );
        self::$ev->add();
    }
1263265
function () {
            this.$Input._init.call(this);
            var label = this.getLabel();
            if (label) {
                ariaUtilsEvent.addListener(label, "click", {
                    fn : this._onLabelClick,
                    scope : this
                });
            }
        }
1080965
public function notify()
    {
        if (0 < count($this->observers)) {
            foreach ($this->observers as $observer) {
                /** @var \Liip\Drupal\Modules\EventManager\EventObserverInterface $observer */
                $observer->update($this);
            }
        }
    }
564255
protected function ensureEventListeners()
	{
		if ($this->_eventListeners === null) {
			$this->_eventListeners = [];
			if (method_exists($this, 'eventListeners')) {
				$this->setEventListeners($this->eventListeners());
			}
		}
	}
123184
public function attach($event, $callback) {
        $events = is_array($event) ? $event : array($event);
        $listeners = $this->getOption(self::OPTION_LISTENERS);
        foreach ($events as $event) {
            $eventObject = is_object($event) ? $event : new GenericEvent($event);
            if (!isset($listeners[$eventObject->getName()])) {
                $listeners[$eventObject->getName()] = array();
            }

            if (!in_array($callback, $listeners[$eventObject->getName()], true)) {
                $listeners[$eventObject->getName()][] = $callback;
            }
        }
        $this->setOption(self::OPTION_LISTENERS, $listeners);
    }
1267402
function() {
			var Klass = this;
			if(Klass.autoBind){
				var $autobound = $(Klass.autoBind);
				/* Bind existing elements */
				$autobound.each(function(){
					Klass.attach($(this));
				});
				/* If a click propagates to the document level, then we have an item that was added later on */
				$(document).on('click', Klass.autoBind, function(evt) {
					if (evt.isDefaultPrevented()) {
						return;
					}
					var $cur = $(evt.currentTarget);
					var len = $autobound.length;
					$autobound = $autobound.add($cur);
					if(len === $autobound.length) {
						return; /* already bound */
					}
					/* Bind featherlight */
					var data = Klass.attach($cur);
					/* Dispatch event directly */
					if (!data.filter || $(evt.target).parentsUntil($cur, data.filter).length > 0) {
						data.handler(evt);
					}
				});
			}
		}
94596
protected function registerEventListeners()
    {
        foreach ($this->events as $event => $listener) {
            Event::listen($event, $listener);
        }

        return $this;
    }