Handles setup or teardown of event hook registration for the provided
        plugin.

        `plugin`
            ``Plugin`` class.
509434
def _setup_events(plugin):
    

    events = plugin.events

    if events and isinstance(events, (list, tuple)):
        for event in [e for e in events if e in _EVENT_VALS]:
            register('event', event, plugin)
349836
protected function _registerPlugin()
    {
        $view = $this->getView();
        $id = $this->options['id'];

        $options = $this->clientOptions !== false && !empty($this->clientOptions)
            ? Json::encode($this->clientOptions)
            : '{}';

        $js[] = "CKEDITOR.replace('$id', $options);";
        $js[] = "skeeks.ckEditorWidget.registerOnChangeHandler('$id');";

        if (isset($this->clientOptions['filebrowserUploadUrl'])) {
            $js[] = "skeeks.ckEditorWidget.registerCsrfImageUploadHandler();";
        }

        $view->registerJs(implode("\n", $js));
    }
433727
def _setup_options(plugin):
    

    options = plugin.options

    if options and isinstance(options, (list, tuple)):
        for props in options:
            if isinstance(props, dict):
                if 'block' in props and 'options' in props:  # block
                    block = props['block']
                    option_list = props['options']

                    # options for this block
                    for props in option_list:
                        if isinstance(props, dict):
                            name = props.pop('name', None)

                            if name:
                                key = "{0}_{1}".format(block, name)
                                register('option', key, plugin, props)

                else:  # non-block option
                    name = props.pop('name', None)

                    if name:
                        register('option', name, plugin, props)
1094956
def _register_hook(hook_name, target, func, *args, **kwargs):
    
    call = (func, args, kwargs)
    try:
        getattr(target, hook_name).append(call)
    except AttributeError:
        setattr(target, hook_name, [call])
996210
public function hooks() {
		// Start and commit the session.
		add_action( 'plugins_loaded', [ $this, 'start_session' ] );
		add_action( 'shutdown', [ $this, 'commit_session' ] );

		// Register the garbage collector.
		add_action( 'wp', [ $this, 'register_garbage_collection' ] );
		add_action( $this->get_schedule_name(), [ $this, 'cleanup_expired_sessions' ] );
	}
404328
def register_hook(self, event, hook):
        """"""

        if event not in self.hooks:
            raise ValueError('Unsupported event specified, with event name "%s"' % (event))

        if isinstance(hook, Callable):
            self.hooks[event].append(hook)
        elif hasattr(hook, '__iter__'):
            self.hooks[event].extend(h for h in hook if isinstance(h, Callable))
1135820
def register(plugin, name=None):
        
        if name is None:
            name = plugin.__name__

        Builder._plugins[nstr(name)] = plugin
893092
def register(self, hook):
        
        assert callable(hook), \
            "Hook must be a callable"
        assert issubclass(hook, HookBase), \
            "The hook does not inherit from HookBase"

        self._registry.append(hook)
126220
def register_plugin(self):
        """"""
        self.main.restore_scrollbar_position.connect(
            self.restore_scrollbar_position)
        self.main.console.edit_goto.connect(self.load)
        self.exec_in_extconsole.connect(self.main.execute_in_external_console)
        self.redirect_stdio.connect(self.main.redirect_internalshell_stdio)
        self.open_dir.connect(self.main.workingdirectory.chdir)
        self.set_help(self.main.help)
        if self.main.outlineexplorer is not None:
            self.set_outlineexplorer(self.main.outlineexplorer)
        editorstack = self.get_current_editorstack()
        if not editorstack.data:
            self.__load_temp_file()
        self.main.add_dockwidget(self)
        self.main.add_to_fileswitcher(self, editorstack.tabs, editorstack.data,
                                      ima.icon('TextFileIcon'))
446856
public function registerPlugin(Swift_Events_EventListener $plugin)
    {
        foreach ($this->transports as $transport) {
            $transport->registerPlugin($plugin);
        }
    }
55313
function registerPlugin(resource, config, silent) {
  let module;

  try {
    module = 'string' == typeof resource ? require(resource) : resource;
  } catch (err) {
    return warn(`unable to load plugin ${strong(resource)}`);
  }

  if (!('register' in module)) return warn(`invalid plugin ${strong(resource)}`);

  module.register(config);
  if (!silent) print(`registered plugin ${strong(module.name)}`, 0);
}
315599
def register(name, klass):
    
    if rapport.config.get_int("rapport", "verbosity") >= 1:
        print("Registered plugin: {0}".format(name))
    _PLUGIN_CATALOG[name] = klass
716533
def unregister(self, plugin=None, name=None):
        
        if name is None:
            assert plugin is not None, "one of name or plugin needs to be specified"
            name = self.get_name(plugin)

        if plugin is None:
            plugin = self.get_plugin(name)

        # if self._name2plugin[name] == None registration was blocked: ignore
        if self._name2plugin.get(name):
            del self._name2plugin[name]

        for hookcaller in self._plugin2hookcallers.pop(plugin, []):
            hookcaller._remove_plugin(plugin)

        return plugin
1362788
protected function registerPlugin() {
		$js = [];

		$view = $this->getView();

		CKEditorAsset::register($view);

		$id = $this->options['id'];

		$options = $this->clientOptions !== false && !empty($this->clientOptions)
			? Json::encode($this->clientOptions)
			: '{}';

		if ($this->disableAutoInline) {
			$js[] = "CKEDITOR.disableAutoInline = true;";
		}
		$js[] = "CKEDITOR.inline('$id', $options);";

		if (isset($this->clientOptions['filebrowserUploadUrl'])) {
			$js[] = "mranger.ckeditorWidget.registerCsrfImageUploadHandler();";
		}

		$view->registerJs(implode("\n", $js));
	}
1064924
private function registerPlugin(Plugin $plugin): void
    {
        if ($this->hasPlugin($plugin->getName())) {
            return;
        }

        $this->plugins[$plugin->getName()] = $plugin;
    }
94273
public function init()
    {
        parent::init();
        self::$plugin = $this;

        $this->preparsedElements = [
            'onBeforeSave' => [],
            'onSave' => [],
            'onMoveElement' => [],
        ];

        // Register our fields
        Event::on(Fields::class, Fields::EVENT_REGISTER_FIELD_TYPES,
            function (RegisterComponentTypesEvent $event) {
                $event->types[] = PreparseFieldType::class;
            }
        );

        // Before save element event handler
        Event::on(Elements::class, Elements::EVENT_BEFORE_SAVE_ELEMENT,
            function (ElementEvent $event) {
                /** @var Element $element */
                $element = $event->element;
                $key = $element->id . '__' . $element->siteId;

                if (!\in_array($key, $this->preparsedElements['onBeforeSave'], true)) {
                    $this->preparsedElements['onBeforeSave'][] = $key;

                    $content = self::$plugin->preparseFieldService->getPreparseFieldsContent($element, 'onBeforeSave');

                    if (!empty($content)) {
                        $this->resetUploads();
                        $element->setFieldValues($content);
                    }
                }
            }
        );

        // After save element event handler
        Event::on(Elements::class, Elements::EVENT_AFTER_SAVE_ELEMENT,
            function (ElementEvent $event) {
                /** @var Element $element */
                $element = $event->element;
                $key = $element->id . '__' . $element->siteId;

                if (!\in_array($key, $this->preparsedElements['onSave'], true)) {
                    $this->preparsedElements['onSave'][] = $key;

                    $content = self::$plugin->preparseFieldService->getPreparseFieldsContent($element, 'onSave');
                    
                    if (!empty($content)) {
                        $this->resetUploads();
                        
                        if ($element instanceof Asset) {
                            $element->setScenario(Element::SCENARIO_DEFAULT);
                        }

                        $element->setFieldValues($content);
                        $success = Craft::$app->getElements()->saveElement($element, true, false);

                        // if no success, log error
                        if (!$success) {
                            Craft::error('Couldn’t save element with id “' . $element->id . '”', __METHOD__);
                        }
                    }
                }
            }
        );

        // After move element event handler
        Event::on(Structures::class, Structures::EVENT_AFTER_MOVE_ELEMENT,
            function (MoveElementEvent $event) {
                /** @var Element $element */
                $element = $event->element;
                $key = $element->id . '__' . $element->siteId;

                if (self::$plugin->preparseFieldService->shouldParseElementOnMove($element) && !\in_array($key, $this->preparsedElements['onMoveElement'], true)) {
                    $this->preparsedElements['onMoveElement'][] = $key;

                    if ($element instanceof Asset) {
                        $element->setScenario(Element::SCENARIO_DEFAULT);
                    }

                    $success = Craft::$app->getElements()->saveElement($element, true, false);

                    // if no success, log error
                    if (!$success) {
                        Craft::error('Couldn’t move element with id “' . $element->id . '”', __METHOD__);
                    }
                }
            }
        );
    }
58577
def register_event(cls, event_name, event, method):
        
        log.info('@Registry.register_event `{}` with subscriber `{}`'
                 .format(event_name, method.__name__))

        if event_name not in cls._events:
            cls._events[event_name] = {}

        if event not in cls._events[event_name]:
            cls._events[event_name][event] = []

        cls._events[event_name][event].append(method)