/** * Check if a wishlist is publicly available, or the * user has special privileges to access it. * * @param $user * @param $wishlist * @return bool */ protected function userCanAccessWishlist(UserInterface $user = null, WishlistInterface $wishlist) { if ($wishlist->isPublic()) { return true; } if ($user) { if ($user->hasRole('ROLE_ADMINISTRATION_ACCESS') || $user->getCustomer() && $user->getCustomer()->getId() == $wishlist->getCustomer()->getId()) { return true; } } return false; }