protected function Negotiator::loadDefaultConsumer in Consumers 8
Finds and loads the default consumer.
Return value
\Drupal\consumers\Entity\Consumer The consumer entity.
Throws
\Drupal\consumers\MissingConsumer
1 call to Negotiator::loadDefaultConsumer()
- Negotiator::doNegotiateFromRequest in src/
Negotiator.php - Obtains the consumer from the request.
File
- src/
Negotiator.php, line 116
Class
- Negotiator
- Extracts the consumer information from the given context.
Namespace
Drupal\consumersCode
protected function loadDefaultConsumer() {
// Find the default consumer.
$results = $this->storage
->getQuery()
->condition('is_default', TRUE)
->execute();
$consumer_id = reset($results);
if (!$consumer_id) {
// Throw if there is no default consumer..
throw new MissingConsumer('Unable to find the default consumer.');
}
/** @var \Drupal\consumers\Entity\Consumer $consumer */
$consumer = $this->storage
->load($consumer_id);
return $consumer;
}