取消事件监听
@param string $name 事件名称
@param mixed $callback 回调，支持回调函数、基于IEventListener的类名
@return void
181949
public function off($name, $callback)
    {
        if(isset($this->events[$name]))
        {
            // 数据映射
            $this->events[$name]->detach($callback);
            $this->eventChangeRecords[$name] = true;
        }
    }
437233
public function set(string $name, callable $callback): void
    {
        $this->services[$name] = function ($c) use ($callback) {
            static $object;

            if ($object === null) {
                $object = $callback($c);
            }

            return $object;
        };
    }
134154
public function make($name, Closure $callback)
    {
        $this->add($name, Menu::make($name, $callback));
    }
675103
public function when($name, callable $callback, callable $default = null, array $context = [])
    {
        if ($this->isActive($name, $context)) {
            return $callback($this->params($name), $context);
        } elseif ($default) {
            return $default($this->params($name), $context);
        }

        return $this;
    }
470633
public function withAttr($name, $callback = null)
    {
        $this->each(function ($model) use ($name, $callback) {
            /** @var Model $model */
            $model && $model->withAttribute($name, $callback);
        });

        return $this;
    }
926651
public function attach($eventName, $callback, $priority = 1): void
    {
        if (!isset($this->listeners[$eventName])) {
            $this->listeners[$eventName] = [];
        }
        if (!isset($this->listeners[$eventName][$priority])) {
            $this->listeners[$eventName][$priority] = [];
        }
        $this->listeners[$eventName][$priority][] = $callback;
    }
131552
public function on($names, $callback)
    {
        if (! is_array($names)) {
            $names = [$names];
        }

        $callable = $this->getCallable($callback);

        foreach ($names as $name) {
            $this->events[] = [
                'name' => $name,
                'callback' => $callable,
            ];
        }
    }
489929
public function add(string $name, callable $callback): self
    {
        call_user_func($this->addCallback, $name, $callback);
        return $this;
    }
423741
protected function buildBasic($name, Closure $callback = null): void
    {
        if ($name instanceof Closure) {
            $callback = $name;
            $name = null;
        }

        ! empty($name) && $this->legend($name);

        $callback($this);
    }
123184
public function attach($event, $callback) {
        $events = is_array($event) ? $event : array($event);
        $listeners = $this->getOption(self::OPTION_LISTENERS);
        foreach ($events as $event) {
            $eventObject = is_object($event) ? $event : new GenericEvent($event);
            if (!isset($listeners[$eventObject->getName()])) {
                $listeners[$eventObject->getName()] = array();
            }

            if (!in_array($callback, $listeners[$eventObject->getName()], true)) {
                $listeners[$eventObject->getName()][] = $callback;
            }
        }
        $this->setOption(self::OPTION_LISTENERS, $listeners);
    }
1142576
public function run($name, $callback) {
        if (!is_callable($callback)) {
            throw new \InvalidArgumentException('$callback is not callable');
        }

        // Because, we need to remove exists Instance before fork
        $this->Storage->setup();

        $pid = pcntl_fork();
        if ($pid === -1) {
            return false;
        }
        if ($pid) {
            // main fork
            $this->pids[$name] = $pid;
            return true;
        } else {
            $result = call_user_func($callback);
            $this->Storage->set($this->getKey(), $name, $result);
            exit(0);
        }
    }
659306
public function registerEvent($event, $callback)
    {
        $eventManager = $this->getServiceLocator()->get(EventManager::CONFIG_ID);
        $eventManager->attach($event, $callback);
        $this->getServiceManager()->register(EventManager::CONFIG_ID, $eventManager);
    }
930434
public function on($event, \Closure $callback): void
    {
        // check if event is a single string and parse it to array single item
        if (!Any::isArray($event)) {
            $event = [$event];
        }
        
        foreach ($event as $item) {
            $this->events[$item][] = $callback;
        }
    }
953948
protected function _bind(array $callback) {
		if (true === empty($callback)) {
			return false;
		}
		array_map(function ($cb) {
			parent::on($cb['event'], $cb['callback']);
		}, $callback);
	}
762522
public function register($name, Closure $callback)
    {
        $this->checkCallbackName($name);

        $this->callbacks[$name] = $callback;

        return $this;
    }
483334
public function filter($name, $callback)
	{
		$this->events->listen('router.filter: '.$name, $this->parseFilter($callback));
	}
500103
public function listen($eventNames, callable $callback)
    {
        if (!is_array($eventNames)) {
            $eventNames = [$eventNames];
        }

        foreach ($eventNames as $eventName) {
            $this->attachListener($eventName, $callback);
        }
    }