/** * @param Path|Url $context * @return static */ public function withContext(Path $context) { if (!$context instanceof Url) { $context = $this->getContext()->with($context); } return parent::withContext($context); }
private function createTargetFromClass($fullClassName, Request $request, Path $context) { $object = $this->factory->getInstance($fullClassName); $nextRequest = $request->withContext($request->getContext()->appendedAll($context->getElements())); $nextRequest = $nextRequest->withTarget(new Path(array_slice($request->getTarget()->getElements(), count($context->getElements())))); if ($object instanceof Responding) { return new RespondingTarget($nextRequest, $object); } else { return new ObjectTarget($nextRequest, $object, $this->factory); } }
public function givenTheRequestHasTheContext($pathString) { $this->request = $this->request->withContext(Path::fromString($pathString)); }