configureRows

@param   array    $items
@param   callable $handler

@return  static
345532
public function configure($items, $handler)
    {
        if (!is_callable($handler)) {
            throw new \InvalidArgumentException(__METHOD__ . ' Handler should be callable.');
        }

        if (!$items instanceof \Traversable && !is_array($items)) {
            throw new \InvalidArgumentException(__METHOD__ . ' items should be array or iterator.');
        }

        foreach ($items as $key => $item) {
            call_user_func($handler, $this, $key, $item);
        }

        return $this;
    }
637772
protected function prepareHandlers(array $handlers)
    {
        foreach ($handlers as $key => $handler) {
            $handlers[$key] = $this->prepareHandler($handler);
        }

        return $handlers;
    }
1025785
public function setHandler($handler = null)
    {
        $this->handler = null !== $handler ? (string)$handler: $handler;

        return $this;
    }
497361
public function setItems($items)
    {
        $this->items = array();

        foreach ($items as $item) {
            $this->addItem($item);
        }

        return $this;
    }
543949
private function setupHandlers($handlers)
    {
        $this->handlers = array();
        foreach ($handlers as $handlerClass => $handlerDetails) {
            $options = array();
            if (isset($handlerDetails[Config::KEY_OPTIONS])) {
                $options = (array)$handlerDetails[Config::KEY_OPTIONS];
            }

            if (isset($handlerDetails[Config::KEY_CLASS])) {
                $handlerClass = $handlerDetails[Config::KEY_CLASS];
            }

            if (!class_exists($handlerClass)) {
                throw new Exception(
                    'Cannot instantiate instance of '.$handlerClass
                );
            }
            $this->handlers[] = new $handlerClass($options);
        }
    }
517154
public function handler($handler, $construct = null)
    {
        $this->handler   = $handler;
        $this->construct = $construct;
        return $this;
    }
110033
public function suscribe($events, Closure $handler)
	{
		if (is_string($events)) $events = [$events];

		// store the handler for each of the events it represents
		foreach ($events as $event)
		{
			// check that we have a place to store the handler
			if (! array_key_exists($event, $this->handlers[static::MESSAGE_TYPE_STANDARD]))
			{
				$this->handlers[static::MESSAGE_TYPE_STANDARD][$event] = [];
			}

			$this->handlers[static::MESSAGE_TYPE_STANDARD][$event][] = $handler;
		}

		// create a new bare message, and store the events
		$m = $this->bareMessage(static::MESSAGE_TYPE_SUSCRIBE);
		$m->Payload['Events'] = $events;

		// finally, send the message
		$this->send($m);
	}
780616
public function setItems(array $items) : self {
      foreach ($items as $item) {
        if (!($item instanceof Token)) {
          throw new \InvalidArgumentException('Expect array of tokens. Token[]');
        }
      }

      $this->items = $items;
      $this->rewind();
      return $this;
    }
539179
public function setHandlers($handlers)
    {
        $this->handlers = $handlers;
        $this->setKey($this->getKey());

        return $this;
    }
1143895
public function setExecutableByHandler($handler)
    {
        list($controller_name, $action_name) = $this->app->getControllerByHandler($handler);
        $controller = $this->app->createController($controller_name);

        $this->setExecutable([$controller, $action_name]);

        return $this;
    }
1082955
public function setRequestHandler($handler)
    {
        $this->requestHandler = $handler;

        $this->requestHandler->setUri($this->url)
            ->setMethod($this->method);

        $this->requestHandler->getUri()->setPort($this->port);

        return $this;
    }
162825
public function start($handler)
    {
        echo PHP_EOL, str_repeat('+', 80), PHP_EOL;

        $settings = isset($this->configure->servers['http']) ? $this->configure->servers['http'] : [];

        if (!empty($settings['enable_static_handler'])) {
            $settings['document_root'] = $_SERVER['DOCUMENT_ROOT'];
            if ($this->configure->debug) {
                $this->log('warn', 'enable `enable_static_handler` setting of swoole will reduce performance!!!!');
                sleep(3);
            }
        }

        if (isset($settings['host'])) {
            $this->_host = $settings['host'];
        }

        if (isset($settings['port'])) {
            $this->_port = (int)$settings['port'];
        }

        $settings['enable_coroutine'] = MANAPHP_COROUTINE ? true : false;

        $this->_settings = $settings;

        $this->_swoole = new \swoole_http_server($this->_host, $this->_port);
        $this->_swoole->set($this->_settings);
        $this->_handler = $handler;

        $this->log('info',
            sprintf('starting listen on: %s:%d with setting: %s', $this->_host, $this->_port, json_encode($this->_settings, JSON_UNESCAPED_SLASHES)));

        $this->_swoole->on('request', [$this, 'onRequest']);

        $this->_swoole->start();
        echo sprintf('[%s][info]: shutdown', date('c')), PHP_EOL;

        return $this;
    }
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;
    }
739986
public function handle($handler = null, array $params = null): ResponseInterface
    {
        $handler = $this->handler($handler);
        $params = $this->params($params);

        $parameters = null;
        if (!$handler instanceof \Closure) {
            [$class, $method] = $this->convert($handler);

            if ($method === null) {
                $key = $handler = $class;
            } else {
                $controller = new $class;
                $handler = [$controller, $method];
                $key = "{$class}::{$method}";
            }

            $parameters = self::optimizeGet($key);
            if ($parameters === false) {
                $parameters = Builder::getCallableParameters($handler, true);
                self::optimizeSet($key, $parameters);
            }
        }

        $result = $this->container->call($handler, $params, $parameters);

        if ($result instanceof ResponseInterface) {
            return $result;
        }

        /** @var Response $response */
        $response = $this->get('response');

        return $response->default($result);
    }
30901
public function setRequestHandler(RequestHandler $handler)
    {
        $handlerName = $handler->getName();
        $this->handlers[$handlerName] = $handler;
        return $this;
    }
1120504
protected function executeHandler($handler, array $parameters)
	{
		if($handler instanceof Closure)
		{
			return $this->executeClosureHandler($handler, $parameters);
		}

		$handler = $this->resolveHandler($handler);

		return $this->executeClassHandler($handler, $parameters);
	}
238285
public function setItems($items)
    {
        if (! is_array($items)) {
            $items = func_get_args();
        }

        $this->addBody($items);

        return $this;
    }