protected function WishlistUserForm::ownerAccess in Commerce Wishlist 8.3
Checks whether the current user owns the given wishlist.
Used to determine whether the user is allowed to modify and share the wishlist.
Parameters
\Drupal\commerce_wishlist\Entity\WishlistInterface $wishlist: The wishlist.
Return value
bool TRUE if the current user owns the given wishlist, FALSE otherwise.
1 call to WishlistUserForm::ownerAccess()
- WishlistUserForm::form in src/
Form/ WishlistUserForm.php - Gets the actual form array to be built.
File
- src/
Form/ WishlistUserForm.php, line 363
Class
- WishlistUserForm
- Provides the wishlist user form.
Namespace
Drupal\commerce_wishlist\FormCode
protected function ownerAccess(WishlistInterface $wishlist) {
if ($this->currentUser
->isAnonymous()) {
// Anonymous wishlists aren't fully implemented yet.
return $this->wishlistSession
->hasWishlistId($wishlist
->id());
}
if ($wishlist
->getOwnerId() != $this->currentUser
->id()) {
return FALSE;
}
if ($this->routeMatch
->getRouteName() != 'entity.commerce_wishlist.user_form') {
// Users should only modify their wishlists via the user form.
return FALSE;
}
return TRUE;
}