Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function getConfigTreeBuilder()
->children()
->booleanNode('multiple')->end()
->booleanNode('default_public')->end()
->booleanNode('account_manageable')->end()
->end();

return $treeBuilder;
Expand Down
1 change: 1 addition & 0 deletions DependencyInjection/WebburzaSyliusWishlistExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function load(array $configs, ContainerBuilder $container)
// Set config parameters
$container->setParameter('webburza_sylius_wishlist.multiple', $config['multiple']);
$container->setParameter('webburza_sylius_wishlist.default_public', $config['default_public']);
$container->setParameter('webburza_sylius_wishlist.account_manageable', $config['account_manageable']);

$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
Expand Down
14 changes: 13 additions & 1 deletion EventListener/AccountMenuBuilderListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,33 @@ class AccountMenuBuilderListener
*/
protected $multipleWishlistMode;

/**
* @var bool
*/
protected $accountManageable;

/**
* FrontendMenuBuilderListener constructor.
*
* @param TranslatorInterface $translator
* @param TokenStorageInterface $tokenStorage
* @param WishlistRepositoryInterface $wishlistRepository
* @param $multipleWishlistMode
* @param $accountManageable
*/
public function __construct(
TranslatorInterface $translator,
TokenStorageInterface $tokenStorage,
WishlistRepositoryInterface $wishlistRepository,
$multipleWishlistMode
$multipleWishlistMode,
$accountManageable
) {

$this->translator = $translator;
$this->tokenStorage = $tokenStorage;
$this->wishlistRepository = $wishlistRepository;
$this->multipleWishlistMode = $multipleWishlistMode;
$this->accountManageable = $accountManageable;
}

/**
Expand All @@ -57,6 +65,10 @@ public function __construct(
*/
public function addAccountMenuItems(MenuBuilderEvent $event)
{
if (!$this->accountManageable) {
return;
}

// Get the menu
$menu = $event->getMenu();

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ to use single or multiple wishlists per user, which can be public or private.
webburza_sylius_wishlist:
multiple: true # multiple wishlist mode
default_public: false # used for automatically created wishlists
account_manageable: true # users can manage their wishlists in their account
```

4. register routes in `app/config/routing.yml`
Expand Down
1 change: 1 addition & 0 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ services:
- '@security.token_storage'
- '@webburza_wishlist.repository.wishlist'
- '%webburza_sylius_wishlist.multiple%'
- '%webburza_sylius_wishlist.account_manageable%'
tags:
- { name: kernel.event_listener, event: sylius.menu.shop.account, method: addAccountMenuItems }

Expand Down