Trigger a hook and return a list of results.
422725
def trigger(self, name, *a, **ka):
        '''  '''
        hooks = self.hooks[name]
        if ka.pop('reversed', False): hooks = hooks[::-1]
        return [hook(*a, **ka) for hook in hooks]
572703
function trigger(context, path, data) {
    if (util.isFunction(_hooksCallbacks[path])) {
        _hooksCallbacks[path].call(context, data, context);
    }
}
971104
def post_run_hook(self, func, prefix=None):
        
        cf = self.capture(func, prefix=prefix)
        self.post_run_hooks.append(cf)
        return cf
225827
def web_hooks(self, include_global=True):
        """"""
        from fabric_bolt.web_hooks.models import Hook
        ors = [Q(project=self)]

        if include_global:
            ors.append(Q(project=None))

        hooks = Hook.objects.filter(reduce(operator.or_, ors))

        return hooks
944663
function triggerEvents (list, args, context) {
  var pass = true

  if (list) {
    var i = 0
    var l = list.length
    var a1 = args[0]
    var a2 = args[1]
    var a3 = args[2]
    // call is faster than apply, optimize less than 3 argu
    // http://blog.csdn.net/zhengyinhui100/article/details/7837127
    switch (args.length) {
      case 0: for (; i < l; i += 2) {pass = list[i].call(list[i + 1] || context) !== false && pass} break
      case 1: for (; i < l; i += 2) {pass = list[i].call(list[i + 1] || context, a1) !== false && pass} break
      case 2: for (; i < l; i += 2) {pass = list[i].call(list[i + 1] || context, a1, a2) !== false && pass} break
      case 3: for (; i < l; i += 2) {pass = list[i].call(list[i + 1] || context, a1, a2, a3) !== false && pass} break
      default: for (; i < l; i += 2) {pass = list[i].apply(list[i + 1] || context, args) !== false && pass} break
    }
  }
  // trigger will return false if one of the callbacks return false
  return pass
}
224493
public function batchRun($is_hook, $method_name, array $params = NULL)
    {
        // Prevents annoying notices.
		if($params == NULL) {
			$params = array();
		}

        // We collect the results into an array.
        $results = array();
        if(!$this->modules) $this->modules = array();
        foreach($this->modules as $name => $module) {
            if(method_exists($module, $method_name)) {
                $result = call_user_func_array(array($module, $method_name), $params);
                if($is_hook) { // Hooks are pre-emptive if they return something.
                    if($result) {
                        return $result;
                    }
                } else { // Collecting
                    $results[$name] = $result;
                }
            }
		}

        return $is_hook? false : $results;
    }
200014
def exec_all_endpoints(self, *args, **kwargs):
        """"""
        results = []
        for handler in self.endpoints:
            if isinstance(handler, weakref.ref):
                handler = handler()
            if self.adapt_params:
                bind = self._adapt_call_params(handler, args, kwargs)
                res = handler(*bind.args, **bind.kwargs)
            else:
                res = handler(*args, **kwargs)
            if isinstance(res, MultipleResults):
                if res.done:
                    results += res.results
                else:
                    results += res._results
            elif res is not NoResult:
                results.append(res)
        return MultipleResults(results, concurrent=self.concurrent, owner=self)
69970
def trigger(self, *args, **kwargs):
		
		current = self.name.split('/')
		while current:
			name = '/'.join(current)
			current.pop()
			if name in self.context.handlers:
				self.all_handlers += [(name, h) for h in self.context.handlers[name]] 
				if name == self.name:
					self.handlers += self.context.handlers[name]

		for name, handler in self.all_handlers:
			res = handler(self, *args, **kwargs)
			self.all_executed += 1
			self.all_result.append(res)
			if name == self.name:
				self.executed += 1
				self.result.append(res)
			if self.stopped:
				break

		self.all_handlers = [h for name, h in self.all_handlers]
221010
function after(results, next) {
    item.trigger('after:' + method, function done(error) {
      next(error, results);
    });
  }
693105
def execute_hook(self, event_name):
        """"""
        hook = self.settings.hooks.get_string('{!s}'.format(event_name))
        if hook is not None and hook != "":
            hook = hook.split()
            try:
                subprocess.Popen(hook)
            except OSError as oserr:
                if oserr.errno == 8:
                    log.error("Hook execution failed! Check shebang at first line of %s!", hook)
                    log.debug(traceback.format_exc())
                else:
                    log.error(str(oserr))
            except Exception as e:
                log.error("hook execution failed! %s", e)
                log.debug(traceback.format_exc())
            else:
                log.debug("hook on event %s has been executed", event_name)
387066
def run_triggers(step, pre_post, args=(), **kwargs):
    '''
    
    '''
    if not isinstance(step, str) or not isinstance(pre_post, str):
        return
    if trace_triggers:
        msg = 'Trigger for %s: %s' % (step, pre_post)
        sys.stderr.write(msg.center(80, '-') + '\n')
    if args is None:
        args = ()
    if not isinstance(args, tuple):
        return
    cfg = __get_config()
    if cfg is None:
        return
    if step not in cfg:
        return
    if not isinstance(cfg[step], dict):
        return
    if pre_post not in cfg[step]:
        return
    d = cfg[step][pre_post]
    l = d.get('cmdlist', [])
    if not l:
        return

    show_output = d.get('show_output', None)
    show_err = d.get('show_err', None)
    ignore_err = d.get('ignore_err', None)

    run_in_order(
        l,
        show_output=show_output,
        show_err=show_err,
        ignore_err=ignore_err,
        args=args,
        pre_post=pre_post,
        kwargs=kwargs
    )
831112
public function triggerHook()
    {
        $hookUrl = $this->getLink('#hook');
        $options = [];

        // The API needs us to send an empty JSON object.
        $options['json'] = new \stdClass();

        // Switch off authentication for this request (none is required).
        $options['auth'] = null;

        $this->sendRequest($hookUrl, 'post', $options);
    }
1317571
def handle_hooks(self, hooks, hook_type, *args):
        '''
        
        '''
        if hook_type not in ['before', 'on_route']:
            hooks = reversed(hooks)

        for hook in hooks:
            result = getattr(hook, hook_type)(*args)
            # on_error hooks can choose to return a Response, which will
            # be used instead of the standard error pages.
            if hook_type == 'on_error' and isinstance(result, WebObResponse):
                return result
701673
def capture_output(self, with_hook=True):
        """"""
        self.hooked = ''

        def display_hook(obj):
            # That's some dirty hack
            self.hooked += self.safe_better_repr(obj)
            self.last_obj = obj

        stdout, stderr = sys.stdout, sys.stderr
        if with_hook:
            d_hook = sys.displayhook
            sys.displayhook = display_hook

        sys.stdout, sys.stderr = StringIO(), StringIO()
        out, err = [], []
        try:
            yield out, err
        finally:
            out.extend(sys.stdout.getvalue().splitlines())
            err.extend(sys.stderr.getvalue().splitlines())
            if with_hook:
                sys.displayhook = d_hook

            sys.stdout, sys.stderr = stdout, stderr
157195
def invoke_hooks(hooks, name, *args, **kwargs):
    

    callbacks = hooks.get(name, [])

    for callback in callbacks:
        callback(*args, **kwargs)
1163866
def register_all_hooks():
    
    global _all_hooks_registered
    if not _all_hooks_registered:
        logger.debug("Searching for hooks")
        hooks = list(get_app_submodules('auth_hooks'))
        logger.debug("Got %s hooks" % len(hooks))
        _all_hooks_registered = True
1373864
def add_result_hook(self, hook: Type["QueryResultHook"]) -> Type["QueryResultHook"]:
        
        hook.next_hook = self._query_result_hook
        self._query_result_hook = hook
        return hook