public function getMergedFields() { return Arrays::mergeDeep($this->fields, $this->files); }
/** * Append the given route match to the current match and resturn a merged result. * * @param RouteMatch $match * @param string $pathPrefix * @return RouteMatch */ public function append(RouteMatch $match, $pathPrefix) { $result = new RouteMatch($this->routeName . $match->routeName, $match->pathPrefix . '/' . ltrim($pathPrefix, '/'), $match->pathRemainder, Arrays::mergeDeep($this->parameters, $match->parameters), $match->handler); return $result; }
public function transformActionArguments(\ReflectionFunctionAbstract $ref, RoutingContextInterface $context) { $request = $context->getRequest(); $match = $context->getRouteMatch(); $instances = [$context, $request, $match]; $args = []; $resolverNeeded = []; // Merge query params with route params, route params have preceedence. $params = Arrays::mergeDeep($request->getUri()->getQuery(), $match->getParameters()); foreach ($ref->getParameters() as $i => $param) { $paramType = $param->getClass(); if ($paramType) { $isRead = false; foreach ($this->plugins->getEntityReaders() as $reader) { $result = $reader->readEntity($context, $paramType, $isRead); if ($isRead) { $args[$i] = $result; continue 2; } } } if (array_key_exists($param->name, $params)) { $value = $params[$param->name]; $isResolved = false; foreach ($this->plugins->getValueConverters() as $converter) { $result = $converter->resolveInput($value, $context, $isResolved, $paramType); if ($isResolved) { $args[$i] = $result; continue 2; } } if ($paramType !== NULL) { $resolverNeeded[$i] = $param; continue; } $args[$i] = $value; continue; } if ($paramType === NULL) { if (!$param->isOptional()) { throw new \InvalidArgumentException(sprintf('Missing value of parameter "%s"', $param->name)); } $args[$i] = $param->isDefaultValueAvailable() ? $param->getDefaultValue() : NULL; continue; } foreach ($instances as $instance) { if ($paramType->isInstance($instance)) { $args[$i] = $instance; continue 2; } } $resolverNeeded[$i] = $param; } foreach ($resolverNeeded as $i => $param) { $paramType = $param->getClass(); $isResolved = false; foreach ($this->plugins->getValueResolvers() as $resolver) { $result = $resolver->resolve($args, $context, $isResolved, $paramType); if ($isResolved) { $args[$i] = $result; continue 2; } } $args[$i] = $this->get($param); } ksort($args, SORT_NUMERIC); return $args; }
/** * Merges query params recursively. * * @param array<string, mixed> $query * @return UriBuilder */ public function queryParams(array $query) { $this->query = Arrays::mergeDeep($this->query, $query); return $this; }