public function WishlistStorage::loadDefaultByUser in Commerce Wishlist 8.3
Loads the default wishlist for the given user.
Parameters
\Drupal\Core\Session\AccountInterface $account: The user.
string $wishlist_type_id: The wishlist type ID.
Return value
\Drupal\commerce_wishlist\Entity\WishlistInterface|null The default wishlist for the given, if known.
Overrides WishlistStorageInterface::loadDefaultByUser
File
- src/
WishlistStorage.php, line 26
Class
- WishlistStorage
- Defines the wishlist storage.
Namespace
Drupal\commerce_wishlistCode
public function loadDefaultByUser(AccountInterface $account, $wishlist_type_id) {
$query = $this
->getQuery();
$query
->condition('uid', $account
->id())
->condition('is_default', TRUE)
->condition('type', $wishlist_type_id)
->sort('is_default', 'DESC')
->sort('wishlist_id', 'DESC')
->range(0, 1)
->accessCheck(FALSE);
$result = $query
->execute();
return $result ? $this
->load(reset($result)) : NULL;
}