/** * Add a menu item for a wishlist. * * @param ItemInterface $menu * @param WishlistInterface $wishlist */ protected function addMenuItemForWishlist(ItemInterface $menu, WishlistInterface $wishlist) { // Use general route (/wishlist) $route = 'webburza_wishlist_frontend_first'; $routeParameters = []; // Route for a specific wishlist if ($this->multipleWishlistMode) { $route = 'webburza_wishlist_frontend_show'; $routeParameters = ['slug' => $wishlist->getSlug()]; } $menu->addChild('webburza_sylius_wishlist_front', ['route' => $route, 'routeParameters' => $routeParameters, 'linkAttributes' => ['title' => $this->translate('webburza.sylius.wishlist.frontend.wishlist')], 'labelAttributes' => ['icon' => 'icon-star', 'iconOnly' => false]])->setLabel($this->translate('webburza.sylius.wishlist.frontend.wishlist')); }
/** * 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; }