Determines the hooks to be run, in which order.

        :param controller: If specified, includes hooks for a specific
                           controller.
502542
def determine_hooks(self, controller=None):
        '''
        
        '''

        controller_hooks = []
        if controller:
            controller_hooks = _cfg(controller).get('hooks', [])
            if controller_hooks:
                return list(
                    sorted(
                        chain(controller_hooks, self.hooks),
                        key=operator.attrgetter('priority')
                    )
                )
        return self.hooks
307045
def set_hooks
      # Final splat var captures any other variables we are not interested in,
      # and avoids them being squashed into the final var.
      eigen_capture(File, [:open, :new], @flag) do |klazz, path, mode, *other|
        add_path(path) if klazz == File && mode =~ /^(t|b)?((w|a)[+]?)(t|b)?$/
      end

      eigen_capture(File, [:rename, :symlink, :link], @flag) do |klazz, old, new, *other|
        add_path(new)
      end

      eigen_capture(Dir, :mkdir, @flag) do |klazz, path, *other|
        add_path(root_dir(path))
      end
    end
1026090
def bind
      Spinach.hooks.tap do |hooks|
        hooks.before_run { |*args| before_run(*args) }
        hooks.after_run { |*args| after_run(*args) }
        hooks.before_feature { |*args| before_feature_run(*args) }
        hooks.after_feature { |*args| after_feature_run(*args) }
        hooks.on_undefined_feature { |*args| on_feature_not_found(*args) }
        hooks.before_scenario { |*args| before_scenario_run(*args) }
        hooks.around_scenario { |*args, &block| around_scenario_run(*args, &block) }
        hooks.after_scenario { |*args| after_scenario_run(*args) }
        hooks.on_successful_step { |*args| on_successful_step(*args) }
        hooks.on_undefined_step { |*args| on_undefined_step(*args) }
        hooks.on_pending_step { |*args| on_pending_step(*args) }
        hooks.on_failed_step { |*args| on_failed_step(*args) }
        hooks.on_error_step { |*args| on_error_step(*args) }
        hooks.on_skipped_step { |*args| on_skipped_step(*args) }

        hooks.before_feature { |*args| set_current_feature(*args) }
        hooks.after_feature { |*args| clear_current_feature(*args) }
        hooks.before_scenario { |*args| set_current_scenario(args.first) }
        hooks.after_scenario { |*args| clear_current_scenario(args.first) }
      end
    end
1361183
def detect_hooks():
    
    flog.debug('Detecting hooks ...')
    present = any([hasattr(hook, 'RENAMER') for hook in sys.meta_path])
    if present:
        flog.debug('Detected.')
    else:
        flog.debug('Not detected.')
    return present
1100477
protected void maybeBuildAndSetGestureDetector(AbstractDraweeController controller) {
    GestureDetector gestureDetector = controller.getGestureDetector();
    if (gestureDetector == null) {
      gestureDetector = GestureDetector.newInstance(mContext);
      controller.setGestureDetector(gestureDetector);
    }
  }
111481
private boolean invokeHook(List<Route> hooks, RouteContext context) throws Exception {
        for (Route hook : hooks) {
            if (hook.getTargetType() == RouteHandler.class) {
                RouteHandler routeHandler = (RouteHandler) hook.getTarget();
                routeHandler.handle(context);
                if (context.isAbort()) {
                    return false;
                }
            } else if (hook.getTargetType() == RouteHandler0.class) {
                RouteHandler0 routeHandler = (RouteHandler0) hook.getTarget();
                routeHandler.handle(context.request(), context.response());
            } else {
                boolean flag = this.invokeHook(context, hook);
                if (!flag) return false;
            }
        }
        return true;
    }
1250286
def for_hook(hook, hook_type = nil)
      unless hook_type
        components = hook.class.name.split('::')
        hook = components.last
        hook_type = components[-2]
      end

      # Merge hook configuration with special 'ALL' config
      hook_config = smart_merge(@hash[hook_type]['ALL'], @hash[hook_type][hook] || {})

      # Need to specially handle `enabled` option since not setting it does not
      # necessarily mean the hook is disabled
      hook_config['enabled'] = hook_enabled?(hook_type, hook)

      hook_config.freeze
    end
1024315
def _execute_hooks(self, element):
        
        if self.hooks and self.finalize_hooks:
            self.param.warning(
                "Supply either hooks or finalize_hooks not both, "
                "using hooks and ignoring finalize_hooks.")
        hooks = self.hooks or self.finalize_hooks
        for hook in hooks:
            try:
                hook(self, element)
            except Exception as e:
                self.param.warning("Plotting hook %r could not be "
                                   "applied:\n\n %s" % (hook, e))
524327
protected function runInitializers()
    {
        $methodName = 'init';
        
        # Run ApplicationController's init method.
        if ($inits = $this->getAppControllersMethod($methodName)) {
            foreach ($inits as $init) {
                $init = $init->bindTo($this);
                $init();
            }
        }
        
        $method = $this->getReflection()->getMethod($methodName);
        if ($method->getDeclaringClass()->getName() == get_called_class()) {
            $this->$methodName();
        }
    }
549305
def _RunSingleHook(self, hook_cls, executed_set, required=None):
    """"""
    # If we already ran do nothing.
    if hook_cls in executed_set:
      return

    # Ensure all the pre execution hooks are run.
    for pre_hook in hook_cls.pre:
      self._RunSingleHook(pre_hook, executed_set, required=hook_cls.__name__)

    # Now run this hook.
    cls_instance = hook_cls()
    if required:
      logging.debug("Initializing %s, required by %s", hook_cls.__name__,
                    required)
    else:
      logging.debug("Initializing %s", hook_cls.__name__)

    # Always call the Run hook.
    cls_instance.Run()
    executed_set.add(hook_cls)

    # Only call the RunOnce() hook if not already called.
    if hook_cls not in self.already_run_once:
      cls_instance.RunOnce()
      self.already_run_once.add(hook_cls)
1016161
def hooks(self, project):
        

        return self.get_queryset().filter(
            Q(project=None) |
            Q(project=project)
        ).distinct('url')
340972
public function initialize(Controller $controller) {
		$this->_controller = $controller;
		if (!$this->_controller->Components->loaded('RequestHandler')) {
			$this->_controller->RequestHandler = $this->_controller->Components->load('RequestHandler');
			$this->_controller->RequestHandler->initialize($this->_controller);
		}
	}
6676
def load_hooks(self, context):
        
        for hook in self.configuration.get('hooks', ()):
            config = hook.get('configuration', {})
            config.update(self.configuration.get('configuration', {}))

            try:
                self._load_hook(hook['name'], config, context)
            except KeyError:
                self.logger.exception('Provided hook has no name: %s.', hook)
644930
function runHooks(request, response, hooks) {
    var promise = Promise.resolve();
    for (var i = 0; i < hooks.length; i++) {
      promise = promise.then(hooks[i].bind(this, request, response));
    }
    return promise;
  }
614143
def run_hook(hook_name, *args)
      list = self.class.all_hooks(hook_name)
      shell = self
      list.each do |hook|
        result = hook.call(shell, *args)
        return :break if result == :break
      end
      list.any?
    end
706576
def _init_request_hooks(self):
        
        for method_type in ('pre', 'post'):
            for method in _METHODS:
                event = getattr(self.app, 'on_' + method_type + '_' + method)
                event_hook = getattr(hooks, method_type + '_' + method)
                event += event_hook
418642
def eval_hooks(self):
        
        logging.debug("Evaluating hooks")
        if self.get_edge_triggered():
            logging.debug("Hook triggered")
            for hook in [h for h in self.edge_hooks if h.is_ready()]:
                logging.debug("Hook invoked")
                hook.invoke()