添加任务响应句柄

@param  string $name
@param  string $handler
485093
public function push(string $name, string $handler)
    {
        if (! isset($this->handlers[$name])) {
            $this->handlers[$name] = [];
        }

        if (! in_array($handler, $this->handlers[$name])) {
            $this->handlers[$name][] = $handler;
        }
    }
621279
public function on(string $event, $handler)
    {
        if (self::isSupportedEvent($event)) {
            $this->options[$event] = $handler;
        }
    }
208974
public function pushDirective($name, $handler, $broken = false)
    {
        if (in_array($name, $this->directivesProtected)) {
            throw new DirectiveNotAllowException('The ' . $name . ' directive is not allow.');
        }

        $this->directives[$name] = compact('handler', 'broken');
    }
754231
final void addHandler(final HttpHandler handler) {
    if (handler != null) {
      if (!eventHandlers.containsKey(handler.getUriSpecification().toLowerCase())) {
        eventHandlers.put(handler.getUriSpecification().toLowerCase(), handler);
      } else {
        LOG.log(Level.WARNING, "JettyHandler handle is already registered: {0} ", handler.getUriSpecification());
      }
    }
  }
313132
public function add($loader, $name = null)
    {
        if (empty($name)) {
            $name = 'loader.' . count($this->loaders);
        }

        $this->loaders[$name] = $loader;
    }
185888
public function addHandler($handler) : MacroProcessor
    {
        if (is_callable($handler)){
            $this->handlers[] = $handler;
        }
        else if ($handler instanceof MacroHandlerInterface){
            $this->handlers[] = array($handler, 'process');
        }
        else if (is_array($handler)){
            $this->handlers[] = function ($keyword) use($handler){
                return $handler[$keyword] ?? null;
            };
        }
        return $this;
    }
222531
public function pipe($name, $handler = null)
    {
        if (is_callable($name)) {
            $handler = $name;
            $name    = null;
        }

        return $handler($this->getRepository($name), $this);
    }
853587
public function addFormField(string $name): void
    {
        $options = $this->formOptions['fields'][$name];
        $wrapper = $this->createWrapper();
        $label = '';

        if (isset($options['label']['text'])) {
            $label = $this->createLabel($options['label']['text'], $name);

            unset($options['label']['text']);
        }

        $input = HtmlTag::createElement('input')
            ->set('type', $options['input']['type'] ?? 'text')
            ->set('id', $name)
            ->set('name', $name);

        $caption = '';

        if (isset($options['caption']['text'])) {
            $input->set('aria-describedby', $name . '_caption');
            $caption = $this->createCaption($options['caption']['text'], $name);

            unset($options['caption']['text']);
        }

        $elements = [
            'wrapper' => $wrapper,
            'label'   => $label,
            'input'   => $input,
            'caption' => $caption
        ];

        foreach ($elements as $name => $element) {
            $$name = $this->assignOptionsToElement($options, $name, $element);
        }

        if (in_array($options['input']['type'] ?? 'text', ['checkbox', 'radio', 'file'])) {
            $wrapper->addElement($input);
            $wrapper->addElement($label);
        } else {
            $wrapper->addElement($label);
            $wrapper->addElement($input);
        }

        $wrapper->addElement($caption);

        echo $wrapper;
    }
359840
public function setHandler(Handler $handler)
    {
        $this->whoops->popHandler();
        $this->handler = $handler;
        $this->whoops->pushHandler($this->handler);
    }
101041
public function handler($name, Args $args)
    {
        if (
            !$this->checkLevel($args->get('level')) ||
            !$this->checkSource($args->get('source'))
        ) {
            return;
        }

        switch ($name) {
            /*
            case ':log:':
                $this->log($args);
                break; // case 'log'

            */
            case ':onAddHandler:':
                $args->set('message', sprintf(
                    "Adding handler %s, %s",
                    $this->handlerToString(
                        $args->get('handler'), $args->get('name')
                    ),
                    $args->get('added', false)
                        ? "successfully" :
                        "failed (duplicate handler)"
                ));
                break; // case ':onAddHandler:'

            case ':onEventStart:':
                $args->set('message', sprintf(
                    "{ '%s' (%s), args [%s]",
                    $args->get('name'),
                    $args->get('uid'),
                    implode(', ', array_keys($args->get()))
                ));
                break; // case ':onEventStart:'

            case ':onHandlerFound:':
                $args->set('message', sprintf(
                    "Handler %s found",
                    $this->handlerToString($args->get('handler'))
                ));
                break; // case ':onAddHandler:'

            case ':onEventEnd:':
                $args->set('message', sprintf(
                    "} '%s' (%s), args [%s]",
                    $args->get('name'),
                    $args->get('uid'),
                    implode(', ', array_keys($args->get()))
                ));
                break; // case ':onEventEnd:'

            case ':onDropHandlers:':
                $args->set('message', sprintf(
                    "Dropping handler %s",
                    $this->handlerToString(
                        $args->get('handler'), $args->get('name')
                    )
                ));
                break; // case ':onDropHandlers:'

            case ':onDisableHandler:':
                $args->set('message', sprintf(
                    "Disabling handler %s",
                    $this->handlerToString(
                        $args->get('handler'), $args->get('name')
                    )
                ));
                break; // case ':onDropHandlers:'

            case ':onEnableHandler:':
                $args->set('message', sprintf(
                    "Enabling handler %s",
                    $this->handlerToString(
                        $args->get('handler'), $args->get('name')
                    )
                ));
                break; // case ':onDropHandlers:'
        }
        $this->log($args);
    }
1218777
private void addHandler(Handler handler, ClassLoader loader)
  {
    // handlers ordered by level
    ArrayList<Handler> handlers = new ArrayList<Handler>();

    handlers.add(handler);

    for (ClassLoader ptr = loader; ptr != null; ptr = ptr.getParent()) {
      Handler []localHandlers = _localHandlers.getLevel(ptr);

      if (localHandlers != null) {
        for (int i = 0; i < localHandlers.length; i++) {
          int p = handlers.indexOf(localHandlers[i]);

          if (p < 0) {
            handlers.add(localHandlers[i]);
          }
          else {
            Handler oldHandler = handlers.get(p);

            if (localHandlers[i].getLevel().intValue()
                < oldHandler.getLevel().intValue()) {
              handlers.set(p, localHandlers[i]);
            }
          }
        }
      }
    }

    Handler []newHandlers = new Handler[handlers.size()];
    handlers.toArray(newHandlers);
    
    if (loader == _systemClassLoader)
      loader = null;

    _localHandlers.set(newHandlers, loader);
  }
106852
public function override(string $name, $handler): void
	{
		$this->clear($name);

		$this->register($name, $handler);
	}
419356
def add_view(self, view_name, handler):
        
        # 如果不是BaseHandler的子类则不加入
        if is_subclass(handler, BaseHandler):
            self.views.append((view_name, handler))
875359
public function loadEvent($name)
    {
        // 1. Load event data only once
        if (isset($this->loadedEvents[$name])) {
            return;
        }
        $this->loadedEvents[$name] = true;

        // 2. Get event handlers
        $events = $this->getEvents();
        if (!isset($events[$name])) {
            return;
        }

        // 3. Attach handlers to event
        $baseMethod = 'on' . ucfirst($name);
        foreach ($events[$name] as $priority => $pluginIds) {
            if ($priority && $priority != static::DEFAULT_PRIORITY) {
                $method = $baseMethod . $priority;
            } else {
                $method = $baseMethod;
            }

            foreach ($pluginIds as $pluginId) {
                $plugin = $this->getById($pluginId);
                if (method_exists($plugin, $method)) {
                    $this->event->on($name, [$plugin, $method], $priority);
                }
            }
        }
    }
261158
function (Handler, name) {
        if (!_.isFunction(Handler.init)) {
            throw new Error('The handler for "' + name + '" does not have an "init" function, which is necessary');
        }

        if (!_.isFunction(Handler.pre)) {
            throw new Error('The handler for "' + name + '" does not have a "pre" function, which is necessary');
        }

        if (!_.isFunction(Handler.post)) {
            throw new Error('The handler for "' + name + '" does not have a "post" function, which is necessary');
        }

        if (!_.isFunction(Handler.sign)) {
            throw new Error('The handler for "' + name + '" does not have a "sign" function, which is necessary');
        }

        Object.defineProperty(Handler, AUTH_TYPE_PROP, {
            value: name,
            configurable: false,
            enumerable: false,
            writable: false
        });

        AuthLoader.handlers[name] = Handler;
    }
253078
public function addHook($name, $behavior, $weight = 0, $key = null)
    {
        if (is_array($behavior)) {
            // 添加多个钩子
            foreach ($behavior as $item) {
                $this->addHook($name, $item, $key, $weight);
            }
        } else {
            isset($this->_hooks[$name]) || $this->_hooks[$name] = [];

            // 避免重复添加
            if (is_null($key)) {
                if ($behavior instanceof \Closure) {
                    $key = md5(time() . rand(1, 10000));
                } else {
                    $key = md5(serialize($behavior));
                }
            }
            $this->_hooks[$name][$key] = $this->formatHook($behavior, $weight, $key);
        }
    }
970380
public synchronized static void addHandler(Handler handler) {
      java.util.logging.Logger root = java.util.logging.LogManager.getLogManager().getLogger(StringUtils.EMPTY);
      root.addHandler(handler);
   }