Register the default events for this controller

@internal
Registers two hooks on "onDispatch":
- change action to form and set mode parameter
- inject sidebar navigation
357385
protected function attachDefaultListeners()
    {
        parent::attachDefaultListeners();
        $events = $this->getEventManager();
        
        /*
         * "Redirect" action 'new' and 'edit' to 'form' and set the 
         * route parameter 'mode' to the original action.
         * This must run before onDispatch, because we alter the action param 
         */
        $events->attach(
            MvcEvent::EVENT_DISPATCH,
            function ($event) {
                $routeMatch = $event->getRouteMatch();
                $action     = $routeMatch->getParam('action');
            
                if ('new' == $action || 'edit' == $action) {
                    $routeMatch->setParam('mode', $action);
                    $routeMatch->setParam('action', 'form');
                }
            },
            10
        );
        
        /*
         * Inject a sidebar view model in the Layout-Model, if 
         * the result in the event is not terminal.
         * This must run after "InjectViewModelListener", which runs with
         * a priority of -100.
         */
        $events->attach(
            MvcEvent::EVENT_DISPATCH,
            function ($event) {
                $model = $event->getResult();
                if (!$model instanceof ViewModel || $model->terminate()) {
                    return;
                }
            
                $routeMatch = $event->getRouteMatch();
                $action = $routeMatch->getParam('action');
                if ('form' == $action) {
                    $action = $routeMatch->getParam('mode');
                }
            
                $layout  = $event->getViewModel();
                $sidebar = new ViewModel();
                $sidebar->setVariable('action', $action);
                $sidebar->setTemplate('auth/sidebar/groups-menu');
                $layout->addChild($sidebar, 'sidebar_auth_groups-menu');
            },
            -110
        );

        $serviceLocator  = $this->serviceLocator;
        $defaultServices = $serviceLocator->get('DefaultListeners');
        $events->attach($defaultServices);
    }
182297
protected function registerListeners()
    {
        $listeners  = (array) $this->get('listeners');
        $dispatcher = $this->getDispatcher();

        $defaultOptions = [
            'class' => '',
            'priority' => ListenerPriority::NORMAL,
            'enabled' => true,
        ];

        foreach ($listeners as $name => $listener) {
            if ($listener instanceof ClassMeta || is_string($listener) || is_callable($listener)) {
                $listener = ['class' => $listener];
            }

            $listener = array_merge($defaultOptions, (array) $listener);

            if (!$listener['enabled']) {
                continue;
            }

            if (!is_numeric($name) && is_callable($listener['class'])) {
                $dispatcher->listen($name, $listener['class']);
            } else {
                $dispatcher->addListener($this->container->newInstance($listener['class']), $listener['priority']);
            }
        }
    }
1020732
public function registerEventListeners()
    {
        if ( $this->loadGlobalEvents )
        {
            $listeners = eZINI::instance()->variable( 'Event', 'Listeners' );
            foreach ( $listeners as $listener )
            {
                // $listener may be empty if some override logic has been involved
                if ( $listener == "" )
                {
                    continue;
                }

                // format from ini is seperated by @
                list( $event, $callback ) = explode( '@', $listener );
                $this->attach( $event, $callback );
            }
        }
    }
1044956
public function init()
    {
        $this->attachBehavior('TbWidget', new TbWidget);
        $this->copyId();
        if ($this->stateful) {
            echo TbHtml::statefulFormTb($this->layout, $this->action, $this->method, $this->htmlOptions);
        } else {
            echo TbHtml::beginFormTb($this->layout, $this->action, $this->method, $this->htmlOptions);
        }
    }
1294099
private function register_event_listener() {

		$cron_array = _get_cron_array();
		if ( ! $cron_array ) {
			return;
		}

		$hooks = array_reduce(
			$cron_array,
			function ( $hooks, $crons ) {

				return array_merge( $hooks, array_keys( $crons ) );
			},
			[]
		);

		$profile_cb = function () {

			$this->cron_action_profile();
		};

		array_walk(
			$hooks,
			function ( $hook ) use ( $profile_cb ) {

				// Please note that "(int) ( PHP_INT_MAX + 1 )" is the lowest possible integer.
				add_action( $hook, $profile_cb, (int) ( PHP_INT_MAX + 1 ) );
				add_action( $hook, $profile_cb, PHP_INT_MAX );
			}
		);

		self::$ran = TRUE;
	}
216494
public function init()
    {
        $this->registerMyJs();
        $display_none = '';

        if (ArrayHelper::remove($this->options, 'displayNone', true) === true) {
            $display_none = Yii::$app->request->get($this->model->formName())['search_form'] ? '' : 'display:none';
        }

        if ($this->submitButtonWrapperOptions !== false) {
            $this->submitButtonWrapperOptions = ArrayHelper::merge([
                'class' => 'col-md-12',
            ], $this->submitButtonWrapperOptions);
        }

        $tag = ArrayHelper::remove($this->options, 'tag', 'div');
        echo Html::beginTag($tag, ArrayHelper::merge([
            'id'    => $this->getDivId(),
            'class' => 'row',
            'style' => 'margin-bottom: 1rem; margin-top: 1rem; ' . $display_none,
        ], $this->options));

        $this->_form = ActiveForm::begin([
            'id'        => 'form-' . $this->getDivId(),
            'action'    => $this->action,
            'method'    => $this->method,
            'options'   => $this->formOptions,
            'fieldClass' => AdvancedSearchActiveField::class,
        ]);
        echo Html::hiddenInput(Html::getInputName($this->model, 'search_form'), 1);
    }
643734
protected function registerEventRebindHandler()
    {
        $this->app->rebinding('events', function ($app, $dispatcher) {
            if (! $app->resolved('auth')) {
                return;
            }

            if (method_exists($guard = $app['auth']->guard(), 'setDispatcher')) {
                $guard->setDispatcher($dispatcher);
            }
        });
    }
978615
def init_actions
      am = action_manager()
      am.add_action(Action.new("&Disable selection") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )
      am.add_action(Action.new("&Edit Toggle") { @edit_toggle = !@edit_toggle; $status_message.value = "Edit toggle is #{@edit_toggle}" })
    end
1277855
protected function InitForm()
    {
        $this->submit = $this->LoadElement();
        
        $this->AddNameField();
        $this->AddValueField();
        
        $this->AddCssIDField();
        $this->AddCssClassField();
        $this->AddTemplateField();
        $this->AddSubmit();
    }
575061
public function registerClientScript()
    {
        $selector = '#' . $this->htmlOptions['id'];

        // do we render a button? If so, bootstrap will handle its behavior through its
        // mark-up, otherwise, register the plugin.
        if (empty($this->buttonOptions)) {
            $this->registerPlugin(TbApi::PLUGIN_MODAL, $selector, $this->options);
        }

        $this->registerEvents($selector, $this->events);
    }
453583
public function defaultAction(): void
    {
        $rootUrl = Http::current() . '/' . $this->view->getLanguage()->getAppliedLang();
        $this->view->header(http::redirect($rootUrl));
    }
1187438
public function init()
    {
        add_action('admin_head', array($this, 'addJsVariables'));
        add_action('admin_enqueue_scripts', array($this, 'enqueue'));
        add_action('current_screen', function ($current_screen) {
            add_action('views_edit-' . $current_screen->post_type, array($this, 'addFilterUrlParams'));
        });
    }
1188286
public function doInit()
    {
        //extension hook
        $this->extend('onBeforeInit');

        // Safety call
        $this->baseInitCalled = false;
        $this->init();
        if (!$this->baseInitCalled) {
            $class = static::class;
            user_error(
                "init() method on class '{$class}' doesn't call Controller::init()."
                . "Make sure that you have parent::init() included.",
                E_USER_WARNING
            );
        }

        $this->extend('onAfterInit');
    }
394567
protected function defaultSubmitEvent()
    {
        $expression = [];

        if ($this->autoClose) {
            $expression[] = "$(this).modal('toggle');";
        }

        if ($this->pjaxContainer) {
            $expression[] = "$.pjax.reload({container : '$this->pjaxContainer', timeout : $this->pjaxTimeout });";
        }

        $script = implode("\r\n", $expression);

        $this->events[self::EVENT_MODAL_SUBMIT] = new JsExpression("
                function(event, data, status, xhr) {
                    if(status){
                        $script
                    }
                }
            ");
    }
293065
public function init_hooks() {
		// Required functionality:
		add_filter( 'user_has_cap',                    array( $this, 'filter_user_has_cap' ), 10, 4 );
		add_filter( 'map_meta_cap',                    array( $this, 'filter_map_meta_cap' ), 10, 4 );
		add_filter( 'user_row_actions',                array( $this, 'filter_user_row_actions' ), 10, 2 );
		add_action( 'plugins_loaded',                  array( $this, 'action_plugins_loaded' ) );
		add_action( 'init',                            array( $this, 'action_init' ) );
		add_action( 'all_admin_notices',               array( $this, 'action_admin_notices' ), 1 );
		add_action( 'wp_logout',                       'user_switching_clear_olduser_cookie' );
		add_action( 'wp_login',                        'user_switching_clear_olduser_cookie' );

		// Nice-to-haves:
		add_filter( 'ms_user_row_actions',             array( $this, 'filter_user_row_actions' ), 10, 2 );
		add_filter( 'login_message',                   array( $this, 'filter_login_message' ), 1 );
		add_filter( 'removable_query_args',            array( $this, 'filter_removable_query_args' ) );
		add_action( 'wp_meta',                         array( $this, 'action_wp_meta' ) );
		add_action( 'wp_footer',                       array( $this, 'action_wp_footer' ) );
		add_action( 'personal_options',                array( $this, 'action_personal_options' ) );
		add_action( 'admin_bar_menu',                  array( $this, 'action_admin_bar_menu' ), 11 );
		add_action( 'bp_member_header_actions',        array( $this, 'action_bp_button' ), 11 );
		add_action( 'bp_directory_members_actions',    array( $this, 'action_bp_button' ), 11 );
		add_action( 'bbp_template_after_user_details', array( $this, 'action_bbpress_button' ) );
	}
42905
protected function bindDefaultTriggers()
    {
        $this->handlers[self::EVENT_INIT]   = $this->fluentCallback([$this, 'handleInit']);
        $this->handlers[self::EVENT_FORK]   = $this->fluentCallback([$this, 'handleFork']);
        $this->handlers[self::EVENT_START]  = $this->fluentCallback([$this, 'handleStart']);
    }
716960
protected function InitForm()
    {
        $this->select  = $this->LoadElement();
        
        $this->AddNameField();
        $this->AddValueField();
        $this->AddLabelField();
        $this->AddOptionsField();
        
        $this->AddDisableFrontendValidationField();
        $this->AddRequiredField();
        $this->AddTemplateField();
        $this->AddCssClassField();
        $this->AddCssIDField();
        $this->AddSubmit();
    }