Call next middleware.

@param   ControllerData $data

@return  string
779541
public function execute($data = null)
    {
        if (class_exists(DebuggerHelper::class)) {
            DebuggerHelper::disableConsole();
        }

        try {
            $result = $this->next->execute($data);

            if ($result instanceof AbstractView) {
                $result = $result->getHandledData();
            }

            $message = $this->getMessage();

            return new JsonBuffer($message, $result);
        } catch (\Exception $e) {
            return $this->handleException($e);
        } catch (\Throwable $t) {
            return $this->handleException(new \ErrorException(
                $t->getMessage(),
                $t->getCode(),
                E_ERROR,
                $t->getFile(),
                $t->getLine(),
                $t
            ));
        }
    }
1123676
public function execute($data = null)
    {
        if (!isset($data->db) || !$data->db instanceof AbstractDatabaseDriver) {
            return $this->next->execute($data);
        }

        /** @var AbstractDatabaseDriver $db */
        $db = $data->db;

        call_user_func($this->getBefore(), $db, $data);

        $result = $this->next->execute($data);

        call_user_func($this->getAfter(), $db, $data);

        return $result;
    }
1092214
protected function run(Data $data)
    {
        $this->router->getContext()->setMethod($data->getMethod());
        $fullUri = $data->getFullUri();

        try {
            $route = $this->router->match($fullUri);
        } catch (ResourceNotFoundException $exception) {
            $route['_route'] = $fullUri;
        }

        if (!empty($route['path'])) {
            $route = $this->router->match($route['path']);
        }

        $kernel = clone $this->kernel;
        $request = $this->request($data, $route);
        $response = $kernel->handle($request);
        $kernel->terminate($request, $response);
        $kernel->shutdown();

        unset(
            $kernel,
            $request,
            $route
        );

        return $response;
    }
811182
public function execute($data = null)
    {
        if (!isset($data->db) || !$data->db instanceof AbstractDatabaseDriver) {
            return $this->next->execute($data);
        }

        if ($data->debug) {
            $this->logger->log(LogLevel::DEBUG, 'Executed: {sql}', ['sql' => $data->sql]);
        }

        try {
            $result = $this->next->execute($data);
        } catch (\RuntimeException $e) {
            // Throw the normal query exception.
            $this->logger->log(
                LogLevel::ERROR,
                'Database query failed (error #{code}): {message}',
                ['code' => $e->getCode(), 'message' => $e->getMessage()]
            );

            throw new $e();
        }

        return $result;
    }
1213806
static function load($controller, $action = '', $params = array())
	{

		$class_name = ucfirst($controller);
		$method = $action;
		$tc = "Controller\\" . $class_name;
		if (!class_exists($tc)) return self::er("Class $tc does not exist.");
		$this_object = new $tc($params);


		if (!method_exists($this_object, $method)) {
			return self::er("Method $method in $tc does not exist.");
		}


		if (!is_callable(array($this_object, $method))) return self::er("Method $method in $tc is not callable.");
		if (is_callable(array($this_object, "__before"))) {
			call_user_func(array($this_object, "__before"));
		}


		call_user_func(array($this_object, $method));

		if (is_callable(array($this_object, "__after"))) {
			call_user_func(array($this_object, "__after"));
		}
		return $this_object;
	}
1229485
public function handle(IPacketData $data)
    {
        if(isset($this->middlewares[$this->index]))
        {
            $middleware = $this->middlewares[$this->index];
            if($middleware instanceof IPacketHandler)
            {
                $requestHandler = $middleware;
            }
            else
            {
                $requestHandler = RequestContext::getServerBean($middleware);
            }
        }
        else
        {
            return null;
        }
        return $requestHandler->process($data, $this->next());
    }
194693
public function commands($name, $data = array())
    {
        $toolbar = $this->_template->getHelper('controller')->getToolbar();

        if (isset($data['clone'])) {
            $toolbar = clone $toolbar;
        }

        if ($toolbar instanceof AnControllerToolbarAbstract) {
            //reset the toolbar
            $toolbar->reset();

            $method = 'add'.ucfirst($name).'Commands';

            if (method_exists($toolbar, $method)) {
                $toolbar->$method();
            }

            return $toolbar->getCommands();
        }
    }
178779
protected function getControllerMiddlewareFromInstance($controller, $method)
    {
        $middleware = $this->router->getMiddleware();

        $results = [];

        foreach ($controller->getMiddleware() as $name => $options) {
            if (!$this->methodExcludedByOptions($method, $options)) {
                $results[$name] = array_get($middleware, $name, $name);
            }
        }

        return $results;
    }
138224
protected function middleware($middlewareName, array $rules = array())
    {
        if (isset($middlewareCache[$middlewareName][json_encode($rules)])) {
            $this->middlewareNext = $middlewareCache[$middlewareName][json_encode($rules)];
        } elseif ($this->middlewareNext === true && $this->class !== false) {
            try {
                $class = "\\OxApp\\middleware\\" . $middlewareName;
                $controller = new  $class();
                $this->middlewareNext = $controller->rules($rules);
                $middlewareCache[$middlewareName][json_encode($rules)] = $this->middlewareNext;
            } catch (\RuntimeException $e) {
                throw new \Exception($e);
            }
        }

        return $this;
    }
1292692
public function handle(Request $request, callable $next)
    {
        $resource       = $request->param('__NAMESPACE__');
        $controllerName = $request->param('__CONTROLLER__');
        $method         = $request->param('__ACTION__');

        if ( $controllerName ) {
            if (FALSE === strstr($controllerName, '\\')) {
                $controllerName = Word::dashToCamelCase($controllerName);
                $controllerName .= 'Controller';
                $controllerName = rtrim($resource, '\\') . '\\' . $controllerName;
            }
        } else {
            $controllerName = $resource;
        }

        if ( FALSE !== strstr($controllerName, '@') ) {
            $controllerName = explode('@', $controllerName);
            $method         = $controllerName[ 1 ];
            $controllerName = $controllerName[ 0 ];
        }

        $method = lcfirst(Word::dashToCamelCase($method));

        $request->set('__CONTROLLER__', $controllerName);
        $request->set('__ACTION__', $method);

        if ( !class_exists($controllerName) ) {
            throw new \Exception(
                sprintf('Class "%s" does not exist', $controllerName),
                Response::HTTP_NOT_FOUND
            );
        }

        if ( !method_exists($controllerName, strtoupper($method)) ) {
            throw new \Exception(
                sprintf(
                    'Method "%s" does not exist in class "%s"',
                    $method,
                    $controllerName
                ),
                Response::HTTP_NOT_FOUND
            );
        }

        $controller = $this->serviceManager->load($controllerName);
        $params     = $request->query();
        $params     = ArrayUtils::merge($params, $request->post(), FALSE, TRUE);
//        $params = ArrayUtils::merge($params, $request->attributes->all(), false, true);

        try {
            $mvcResponse = $this->serviceManager->call(
                [
                    $controller,
                    $method
                ],
                $params
            );
        } catch (ValidationError $error) {
            $method = $request->post('__PREVIOUS__', 'get');

            $mvcResponse = $this->serviceManager->call(
                [
                    $controller,
                    strtolower($method)
                ],
                $params
            );
        }

        if ( $mvcResponse instanceof Response ) {
            return $mvcResponse;
        }

        $mvcResponse = new DispatchResult(
            $mvcResponse,
            $controllerName,
            $method
        );

        $result = $next($request);
        if ( $result ) {
            return $result;
        }

        return $mvcResponse;
    }
501517
public function next($data)
    {
        if ($this->destinations!=null) {
            foreach ($this->destinations as $node) {
                $node->input($data, $this);
            }
        }
    }
1273901
function callMiddlewares(actionName, actionData, done) {
    let store = this;
    let index = -1;
    /**
     * Call next middleware or done
     * @function next
     * @param {*} actionData - An action data
     */
    function next(actionData) {
        index++;
        if(index === store.middlewares.length) {
            done(actionData);
        } else {
            store.middlewares[index](store, actionName, actionData, next);
        }
    }
    next(actionData);
}
674261
public function call(string $event, $data = null)
    {
        if (! $this->eventExists($event)) {
            return null;
        }

        // inject request param on connect event
        $isConnect = $event === static::EVENT_CONNECT;
        $dataKey = $isConnect ? 'request' : 'data';

        // dispatch request to pipeline if middleware are set
        if ($isConnect && count($this->middleware)) {
            $data = $this->setRequestThroughMiddleware($data);
        }

        return App::call($this->callbacks[$event], [
            'websocket' => $this,
            $dataKey => $data,
        ]);
    }
490601
protected function handleDispatch($data)
    {
        if (! is_null($hData = $this->handlers->getHandler($data->t))) {
            $handler = new $hData['class'](
                $this->http,
                $this->factory,
                $this->cache,
                $this
            );

            $deferred = new Deferred();
            $deferred->promise()->then(function ($d) use ($data, $hData) {
                if (is_array($d) && count($d) == 2) {
                    list($new, $old) = $d;
                } else {
                    $new = $d;
                    $old = null;
                }

                $this->emit($data->t, [$new, $this, $old]);

                foreach ($hData['alternatives'] as $alternative) {
                    $this->emit($alternative, [$d, $this]);
                }

                if ($data->t == Event::MESSAGE_CREATE && mentioned($this->client->user, $new)) {
                    $this->emit('mention', [$new, $this, $old]);
                }
            }, function ($e) use ($data) {
                $this->logger->warning('error while trying to handle dispatch packet', ['packet' => $data->t, 'error' => $e]);
            }, function ($d) use ($data) {
                $this->logger->warning('notified from event', ['data' => $d, 'packet' => $data->t]);
            });

            $parse = [
                Event::GUILD_CREATE,
            ];

            if (! $this->emittedReady && (array_search($data->t, $parse) === false)) {
                $this->unparsedPackets[] = function () use (&$handler, &$deferred, &$data) {
                    $handler->handle($deferred, $data->d);
                };
            } else {
                $handler->handle($deferred, $data->d);
            }
        }

        $handlers = [
            Event::VOICE_SERVER_UPDATE => 'handleVoiceServerUpdate',
            Event::RESUMED             => 'handleResume',
            Event::READY               => 'handleReady',
            Event::GUILD_MEMBERS_CHUNK => 'handleGuildMembersChunk',
            Event::VOICE_STATE_UPDATE  => 'handleVoiceStateUpdate',
        ];

        if (isset($handlers[$data->t])) {
            $this->{$handlers[$data->t]}($data);
        }
    }
222462
public function sendData($data)
    {
        $httpResponse = $this->sendRequest($data);

        $responseClass = $this->getResponseClassName();
        return $this->response = new $responseClass($this, $httpResponse);
    }
1150030
public function createNew($data)
    {
        foreach ($this->handlers as $handler) {
            $result = $handler->createNew($data);
            if ($result) {
                return $result;
            }
        }

        return null;
    }
1246278
public function execute($data = null)
    {
        $data->repository->transactionStart(true);

        try {
            $result = $this->next->execute($data);
        } catch (\Throwable $e) {
            $data->repository->transactionRollback(true);

            throw $e;
        }

        $data->repository->transactionCommit(true);

        return $result;
    }