You are here

public function WishlistController::userPage in Commerce Wishlist 8.3

Builds the user wishlist page.

If the customer doesn't have a wishlist, or the wishlist is empty, the "empty page" will be shown. Otherwise, the customer will be redirected to the default wishlist.

Return value

array|\Symfony\Component\HttpFoundation\RedirectResponse A render array, or a redirect response.

1 string reference to 'WishlistController::userPage'
commerce_wishlist.routing.yml in ./commerce_wishlist.routing.yml
commerce_wishlist.routing.yml

File

src/Controller/WishlistController.php, line 137

Class

WishlistController
Provides the wishlist pages.

Namespace

Drupal\commerce_wishlist\Controller

Code

public function userPage() {
  $wishlist = $this->wishlistProvider
    ->getWishlist($this
    ->getDefaultWishlistType());
  if (!$wishlist || !$wishlist
    ->hasItems()) {
    return [
      '#theme' => 'commerce_wishlist_empty_page',
    ];
  }
  $url = $wishlist
    ->toUrl('user-form', [
    'absolute' => TRUE,
  ]);
  return new RedirectResponse($url
    ->toString());
}