Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restricted zones, fixes #624 #665

Merged
merged 4 commits into from
Dec 3, 2013
Merged

Conversation

umpirsky
Copy link
Contributor

No description provided.

@@ -15,7 +15,7 @@
use Sylius\Bundle\PromotionsBundle\Processor\PromotionProcessorInterface;
use Sylius\Bundle\PromotionsBundle\SyliusPromotionEvents;
use Symfony\Component\EventDispatcher\GenericEvent;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point of replacing interface with implementation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then change implementation to use what is in interface & not use shortcut:

$session->getBag('flashes')->add();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right.
On 28 Nov 2013 20:19, "Joseph Bielawski" notifications@github.com wrote:

In src/Sylius/Bundle/CoreBundle/EventListener/OrderPromotionListener.php:

@@ -15,7 +15,7 @@
use Sylius\Bundle\PromotionsBundle\Processor\PromotionProcessorInterface;
use Sylius\Bundle\PromotionsBundle\SyliusPromotionEvents;
use Symfony\Component\EventDispatcher\GenericEvent;
-use Symfony\Component\HttpFoundation\Session\SessionInterface;

Then change implementation to use what is in interface & not use shortcut:

$session->getBag('flashes')->add();


Reply to this email directly or view it on GitHubhttps://github.com//pull/665/files#r7991055
.

@stloyd
Copy link
Contributor

stloyd commented Nov 28, 2013

@umpirsky Here is IMO better approach umpirsky#1 it uses ItemResolver and not listeners.

@pjedrzejewski
Copy link
Member

I prefer @stloyd's approach.

@umpirsky
Copy link
Contributor Author

Yes, it is better @stloyd, thanks.

But now I get generic flash message "Error occurred while adding item to cart.", and it was more precise before with "This product is not available in your country.".

@winzou
Copy link
Contributor

winzou commented Nov 29, 2013

We need anyway a serious improvement on error feedback from ItemResolver. It's currently way too generic (what if form has errors? We only show "error occurred" in cart summary and don't even get the user back to the product page!)

@stloyd
Copy link
Contributor

stloyd commented Nov 29, 2013

@umpirsky If you see that error, not message from exception, than it looks like a bug in FlashListener as it should try to get message from event (it's set in controller & taken from exception) and if not found use the default one mentioned by you...

@winzou I tend to agree, but let's stop messing with stuff that not belongs to current PR, and just create new issue describing the problem & maybe possible solutions to avoid mud & unnecessary blocking of PR fixing totally different issue =)

@umpirsky
Copy link
Contributor Author

@stloyd Yes, I assumed same. In https://github.com/Sylius/Sylius/blob/master/src/Sylius/Bundle/CartBundle/Controller/CartItemController.php#L60 event subject is error message, but in https://github.com/Sylius/Sylius/blob/master/src/Sylius/Bundle/CartBundle/EventListener/FlashListener.php#L85 message is used, and not subject. I'm not sure what is the idea there, but obviously same thing should be used on both places. Is it message or subject? cc @pjedrzejewski

@stloyd
Copy link
Contributor

stloyd commented Nov 29, 2013

@umpirsky @pjedrzejewski Here is an fix for Cart flash messages: #670


foreach ($cart->getItems() as $item) {
if ($this->restrictedZoneChecker->isRestricted($product = $item->getProduct())) {
$cart->removeItem($item);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stloyd Do I need to:

$this->dispatchEvent(SyliusCartEvents::ITEM_REMOVE_INITIALIZE, $event);

or

$this->cartManager->persist($cart);
$this->cartManager->flush();

here in order to persist cart?

Because now it's not persisted.

cc @pjedrzejewski

@umpirsky
Copy link
Contributor Author

umpirsky commented Dec 2, 2013

@stloyd @pjedrzejewski Good to merge?

pjedrzejewski pushed a commit that referenced this pull request Dec 3, 2013
@pjedrzejewski pjedrzejewski merged commit c10fa44 into Sylius:master Dec 3, 2013
@pjedrzejewski
Copy link
Member

Thank you Sasha! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Minor issues and PRs improving the current solutions (optimizations, typo fixes, etc.).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants