public function Negotiator::negotiateFromRequest in Consumers 8
Obtains the consumer from the request.
Parameters
\Symfony\Component\HttpFoundation\Request|null $request: The request object to inspect for a consumer. Set to NULL to use the current request.
Return value
\Drupal\consumers\Entity\Consumer|null The consumer.
Throws
\Drupal\consumers\MissingConsumer
File
- src/
Negotiator.php, line 100
Class
- Negotiator
- Extracts the consumer information from the given context.
Namespace
Drupal\consumersCode
public function negotiateFromRequest(Request $request = NULL) {
// If the request is not provided, use the request from the stack.
$request = $request ? $request : $this->requestStack
->getCurrentRequest();
$consumer = $this
->doNegotiateFromRequest($request);
$request->attributes
->set('consumer_uuid', $consumer
->uuid());
return $consumer;
}