Build the array structure for value.

@param $route
@param null $data
@return array|null
499086
private function buildArray($route, $data = null)
    {
        $key  = array_pop($route);
        $data = [$key => $data];
        if (count($route) == 0) {
            return $data;
        }
        return $this->buildArray($route, $data);
    }
1159848
protected function parseData(Query $query, $data)
    {
        if (empty($data)) {
            return [];
        }

        $result = [];

        foreach ($data as $key => $val) {
            $item = $this->parseKey($key);

            if (is_object($val)) {
                $result[$item] = $val;
            } elseif (isset($val[0]) && 'exp' === $val[0]) {
                $result[$item] = $val[1];
            } elseif (is_null($val)) {
                $result[$item] = 'NULL';
            } else {
                $result[$item] = $this->parseValue($query, $val, $key);
            }
        }

        return $result;
    }
86168
public function createGroup(array $routes = array(), Route $route = null)
    {
        return $this->create('group', array($this, $route, $routes));
    }
1043072
protected function ensureNativeArray($dataValues, $path)
    {
        if (\is_array($dataValues)) {
            return $dataValues;
        }

        // Converting traversable to standard array
        if ($dataValues instanceof \Traversable) {
            $arrayDataValues = [];
            foreach ($dataValues as $key => $dataValue) {
                $arrayDataValues[$key] = $dataValue;
            }

            return $arrayDataValues;
        }

        $type = \is_object($dataValues) ? \get_class($dataValues) : \gettype($dataValues);
        throw new InvalidValueDataException(
            "Value for collection for path '{$path}' must be an array, '{$type}' given"
        );
    }
773422
private function extractFunctionFromRoute(Route $route)
    {
        $controller = explode('::', $this->extractControllerDefaultFromRoute($route));

        return isset($controller[1]) ? $controller[1] : null;
    }
139495
public function generateRouterData(array $routes, ?callable $transform = null): array
    {
        $static = [];
        $dynamic = [];
        
        foreach ($routes as $route) {
            $compiled = $this->compileRoute($route);
            
            if ($compiled[self::KEY_REGEX] === '') {
                $prefix = $compiled[self::KEY_PREFIX];
                $route = $compiled[self::KEY_ROUTE];
                
                if (isset($static[$prefix])) {
                    if (\is_array($static[$prefix])) {
                        $static[$prefix][] = $route;
                    } else {
                        $static[$prefix] = [
                            $static[$prefix],
                            $route
                        ];
                    }
                } else {
                    $static[$prefix] = $route;
                }
            } else {
                $dynamic[] = $compiled;
            }
        }
        
        \usort($dynamic, static function (array $a, array $b): int {
            $p = ($b[self::KEY_PRIORITY] <=> $a[self::KEY_PRIORITY]);
            
            if ($p !== 0) {
                return $p;
            }
            
            $p = \strcmp($a[self::KEY_PREFIX], $b[self::KEY_PREFIX]);
            
            if ($p !== 0) {
                return $p;
            }
            
            return \strcmp($a[self::KEY_REGEX], $b[self::KEY_REGEX]);
        });
        
        $matches = \array_column($dynamic, 0);
        $grouped = [];
        
        $regex = "'^(?";
        
        for ($len = \count($dynamic), $i = 0; $i < $len; $i++) {
            if (isset($dynamic[$i + 1]) && $dynamic[$i + 1][self::KEY_PREFIX] == $dynamic[$i][self::KEY_PREFIX]) {
                $regex .= '|' . \preg_quote($dynamic[$i][self::KEY_PREFIX], "'") . '(?';
                
                $tmp = [
                    $dynamic[$i][self::KEY_REGEX] => [
                        $i => $dynamic[$i][self::KEY_PRIORITY]
                    ]
                ];
                
                do {
                    $i++;
                    
                    $tmp[$dynamic[$i][self::KEY_REGEX]][$i] = $dynamic[$i][self::KEY_PRIORITY];
                } while (isset($dynamic[$i + 1]) && $dynamic[$i + 1][self::KEY_PREFIX] == $dynamic[$i][self::KEY_PREFIX]);
                
                foreach ($tmp as & $t) {
                    \arsort($t, \SORT_NUMERIC);
                }
                
                foreach ($tmp as $k => $v) {
                    $regex .= '|' . $k . '(*MARK:G' . \count($grouped) . ')';
                    $grouped[] = \count($v);
                    
                    if ($transform) {
                        $grouped = \array_merge($grouped, \array_map(static function (int $i) use ($dynamic, $transform) {
                            return $transform($dynamic[$i][self::KEY_ROUTE], $i);
                        }, \array_keys($v)));
                    } else {
                        $grouped = \array_merge($grouped, \array_keys($v));
                    }
                }
                
                $regex .= ')';
            } else {
                $regex .= '|' . \preg_quote($dynamic[$i][self::KEY_PREFIX], "'") . $dynamic[$i][self::KEY_REGEX] . '(*MARK:R' . $i . ')';
            }
        }
        
        $regex .= ")$'i";
        
        return [
            $static,
            $regex,
            $matches,
            $grouped,
            $routes
        ];
    }
1312504
static public function view($route, $view = null, array $data = [])
    {
        self::$instance->register('GET', $route, null, $view, $data);
    }
1091586
public function get_data($path=NULL) {
		$myIndexList = array();
		$path = $this->fix_path($path);
		
		if(is_null($path) || (strlen($path) < 1)) {
			//they just want ALL THE DATA.
			$retval = $this->data;
		}
		else {
			//get the list of indices in our data that we have to traverse.
			$myIndexList = $this->explode_path($path);
			
			//set an initial retval.
			$retval = $this->get_data_segment($this->data, $myIndexList[0]); 
			unset($myIndexList[0]);
			
			if(count($myIndexList) > 0) {
				foreach($myIndexList as $indexName) {
					$retval = $this->get_data_segment($retval, $indexName);
					if(is_null($retval)) {
						//hmm... well, if it's null, it's nothing which can have a sub-index.  Stop here.
						break;
					}
				}
			}
		}
		
		return($retval);
		
	}
100141
public function contentForInternalRoute($route = null)
    {
        // Get the route
        if (is_null($route)) {
            $route = $this->di->get("request")->getRoute();
        }

        // Check cache for content or create cached version of content
        $slug = $this->di->get("url")->slugify($route);
        $key = $this->di->cache->createKey(__CLASS__, "route-$slug");
        $content = $this->di->cache->get($key);

        if (!$content || $this->ignoreCache) {
            $content = $this->createContentForInternalRoute($route);
            $this->di->cache->put($key, $content);
        }

        return $content;
    }
649943
private function routeRegexp(Route $route, array $data = null) : string
    {
        $regexp = $route->getMatch();

        // AbstractApp::logger()->debug($regexp);

        preg_match_all('`\{\{(.+)\}\}`U', $regexp, $matches);
        if (sizeof($matches[1]) == 0) {
            return $regexp;
        }

        foreach ($matches[1] as $var) {
            $replace = '{{' . $var . '}}';
            $explode = explode(':', $var);
            $type = array_shift($explode);
            $value = implode(':', $explode);
            unset($dest);

            switch ($type) {
                case 'T':
                    $dest = $this->routeRegexpTranslatedText($route, $value, $data);
                    break;

                case 'L':
                    $dest = $this->routeRegexpLocales($data);
                    break;

                case 'C': // mandatory capture variable with optionnal regexp
                case 'O': // optionnal capture variable with optionnal regexp
                case 'S': // uncapture text with optionnal regexp
                    $dest = $this->routeRegexpCapture($type, $route, $value, $data);
                    break;

                default:
                    throw new \InvalidArgumentException(
                        sprintf("Invalid route variable '%s' on route '%s'", $type, $route->getName())
                    );
            }

            $regexp = str_replace(
                $replace,
                isset($dest) ? $dest : '',
                $regexp
            );
        }

        return $regexp;
    }
715505
public function offsetGet($route){
    $return_value = null;
    if(isset($this->routes[$route])){
      $return_value = $routes[$route];
    }

    return $return_value;
  }
32118
protected function getRouteInformation(Route $route, $filter, $namespace)
    {
        $data = parent::getRouteInformation($route, $filter, $namespace);

        if (!$data || empty($data['name'])) {
            return null;
        }

        return array_only($data, ['uri', 'name']);
    }
1011716
private function extractVariableRouteParts(string $route) : array
    {
        $matches = [];
        preg_match_all(
            self::VARIABLE_REGEX,
            $route,
            $matches,
            PREG_OFFSET_CAPTURE | PREG_SET_ORDER
        );

        return $matches;
    }
1314197
public static function make($data = null, $index = null, Closure $modifier = null)
    {
        if ($data instanceof Traversable) {
            $data = iterator_to_array($data);
        }

        if (!is_array($data)) {
            return null;
        }

        if (count($data) < 1) {
            return [];
        }

        // Check if it is a multi dimensional array
        $values = array_values($data);
        $multi  = array_key_exists(0, $values) && is_array($values[0]);


        if ($multi) {
            $list = [];
            foreach ($data as $item) {
                if ($index && array_key_exists($index, $item)) {
                    $key        = $item[$index];
                    $list[$key] = static::populate($item, $modifier);
                    continue;
                }
                $list[] = static::populate($item, $modifier);
            }

            return $list;
        }

        return static::populate($data, $modifier);
    }
1174512
public function create($routeName, array $data = array(), array $query = array())
    {
        if(strpos($routeName, '@') === 0)
            $route = $this->rootRouter->findRoute(substr($routeName, 1));
        else
            $route = $this->map->findRoute($routeName);

        if(!$route)
            throw new NotFoundException('Unable to find route ['.$routeName.']');

        $path = $route->getAbsolutePath($data);

        return $this->base($path).($query ? '?'. http_build_query($query) : null);
    }
930085
function formatToArrayStandard($route = null,array $parameters = array()) {
        $links = array(
            'self'  => array('href' => ''),
            'first' => array('href' => ''),
            'last'  => array('href' => ''),
            'next'  => array('href' => ''),
            'previous'  => array('href' => ''),
        );
        $paginator = array(
                        'currentPage' => $this->getCurrentPage(),
                        'maxPerPage' => $this->getMaxPerPage(),
                        'totalPages' => $this->getNbPages(),
                        'totalResults' => $this->getNbResults(),
                    );
        
        $pageResult = $this->getCurrentPageResults();
        if(is_array($pageResult)){
            $results = $pageResult;
        }else{
            $results = $this->getCurrentPageResults()->getArrayCopy();
        }
        return array(
            'links' => $this->getLinks($route,$parameters),
            'meta' => $paginator,
            'data' => $results,
        );
    }
839452
public static function toAjax($route, array $params = [])
    {
        $routeParams = ['/'.$route];
        foreach ($params as $key => $value) {
            $routeParams[$key] = $value;
        }
        
        return static::toInternal($routeParams, true);
    }