private function addOptionsToTable(Route $route, array &$row) { $options = $route->getOptions(); unset($options['middleware']); unset($options['middlewares']); if (empty($options)) { $row[] = " "; } else { foreach ($options as $key => $val) { if (is_array($val) && $key !== 'middleware' && $key !== 'middlewares') { $row[] = "{$key}:" . json_encode($options[$key], JSON_PRETTY_PRINT); } elseif ($key !== 'middleware' && $key !== 'middlewares') { $row[] = $options[$key]; } } } }
/** * Wraps the controller or function into a callable closure * * @param RouteInterface $route * @return \Closure * @throws \HttpRuntimeException */ protected function getNextCallable(RouteInterface $route) { $controller = $route->getController(); $controllerMethod = $route->getControllerMethod(); $namespace = $this->getControllerNamespace(); $payload = $route->getRouteParameters(); if (is_callable($controller)) { $args = $this->getFunctionArgs($controller); $next = function () use($controller, $args) { return call_user_func_array($controller, $args); }; } else { if (strContains('\\', $controller)) { $class = $controller; } else { $class = $namespace . '\\' . $controller; } if (class_exists($class, true)) { $obj = $this->makeController($class); $obj->setApplication($this->application); $args = $this->getFunctionArgs($controller, $controllerMethod); $next = function () use($obj, $args, $controllerMethod, $payload) { return $this->runController($obj, $controllerMethod, $args); }; } else { throw new ControllerNotFoundException(); } } return $next; }