mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
[Shop] Rename and move order id listener
This commit is contained in:
parent
3c2771b1fd
commit
63dac97e00
6 changed files with 43 additions and 17 deletions
|
|
@ -67,6 +67,7 @@ suites:
|
||||||
SequenceBundle: { namespace: Sylius\Bundle\SequenceBundle, psr4_prefix: Sylius\Bundle\SequenceBundle, spec_path: src/Sylius/Bundle/SequenceBundle, src_path: src/Sylius/Bundle/SequenceBundle }
|
SequenceBundle: { namespace: Sylius\Bundle\SequenceBundle, psr4_prefix: Sylius\Bundle\SequenceBundle, spec_path: src/Sylius/Bundle/SequenceBundle, src_path: src/Sylius/Bundle/SequenceBundle }
|
||||||
SettingsBundle: { namespace: Sylius\Bundle\SettingsBundle, psr4_prefix: Sylius\Bundle\SettingsBundle, spec_path: src/Sylius/Bundle/SettingsBundle, src_path: src/Sylius/Bundle/SettingsBundle }
|
SettingsBundle: { namespace: Sylius\Bundle\SettingsBundle, psr4_prefix: Sylius\Bundle\SettingsBundle, spec_path: src/Sylius/Bundle/SettingsBundle, src_path: src/Sylius/Bundle/SettingsBundle }
|
||||||
ShippingBundle: { namespace: Sylius\Bundle\ShippingBundle, psr4_prefix: Sylius\Bundle\ShippingBundle, spec_path: src/Sylius/Bundle/ShippingBundle, src_path: src/Sylius/Bundle/ShippingBundle }
|
ShippingBundle: { namespace: Sylius\Bundle\ShippingBundle, psr4_prefix: Sylius\Bundle\ShippingBundle, spec_path: src/Sylius/Bundle/ShippingBundle, src_path: src/Sylius/Bundle/ShippingBundle }
|
||||||
|
ShopBundle: { namespace: Sylius\Bundle\ShopBundle, psr4_prefix: Sylius\Bundle\ShopBundle, spec_path: src/Sylius/Bundle/ShopBundle, src_path: src/Sylius/Bundle/ShopBundle }
|
||||||
TaxationBundle: { namespace: Sylius\Bundle\TaxationBundle, psr4_prefix: Sylius\Bundle\TaxationBundle, spec_path: src/Sylius/Bundle/TaxationBundle, src_path: src/Sylius/Bundle/TaxationBundle }
|
TaxationBundle: { namespace: Sylius\Bundle\TaxationBundle, psr4_prefix: Sylius\Bundle\TaxationBundle, spec_path: src/Sylius/Bundle/TaxationBundle, src_path: src/Sylius/Bundle/TaxationBundle }
|
||||||
TaxonomyBundle: { namespace: Sylius\Bundle\TaxonomyBundle, psr4_prefix: Sylius\Bundle\TaxonomyBundle, spec_path: src/Sylius/Bundle/TaxonomyBundle, src_path: src/Sylius/Bundle/TaxonomyBundle }
|
TaxonomyBundle: { namespace: Sylius\Bundle\TaxonomyBundle, psr4_prefix: Sylius\Bundle\TaxonomyBundle, spec_path: src/Sylius/Bundle/TaxonomyBundle, src_path: src/Sylius/Bundle/TaxonomyBundle }
|
||||||
ThemeBundle: { namespace: Sylius\Bundle\ThemeBundle, psr4_prefix: Sylius\Bundle\ThemeBundle , spec_path: src/Sylius/Bundle/ThemeBundle, src_path: src/Sylius/Bundle/ThemeBundle }
|
ThemeBundle: { namespace: Sylius\Bundle\ThemeBundle, psr4_prefix: Sylius\Bundle\ThemeBundle , spec_path: src/Sylius/Bundle/ThemeBundle, src_path: src/Sylius/Bundle/ThemeBundle }
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,6 @@
|
||||||
<parameter key="sylius.listener.customer_reviews_delete.class">Sylius\Bundle\CoreBundle\EventListener\CustomerReviewsDeleteListener</parameter>
|
<parameter key="sylius.listener.customer_reviews_delete.class">Sylius\Bundle\CoreBundle\EventListener\CustomerReviewsDeleteListener</parameter>
|
||||||
<parameter key="sylius.listener.order_recalculation.class">Sylius\Bundle\CoreBundle\EventListener\OrderRecalculationListener</parameter>
|
<parameter key="sylius.listener.order_recalculation.class">Sylius\Bundle\CoreBundle\EventListener\OrderRecalculationListener</parameter>
|
||||||
<parameter key="sylius.listener.user_cart_recalculation.class">Sylius\Bundle\CoreBundle\EventListener\UserCartRecalculationListener</parameter>
|
<parameter key="sylius.listener.user_cart_recalculation.class">Sylius\Bundle\CoreBundle\EventListener\UserCartRecalculationListener</parameter>
|
||||||
<parameter key="sylius.listener.store_order_id.class">Sylius\Bundle\CoreBundle\EventListener\StoreOrderIdListener</parameter>
|
|
||||||
|
|
||||||
<parameter key="sylius.active_promotions_by_channel_provider.class">Sylius\Component\Core\Provider\ActivePromotionsByChannelProvider</parameter>
|
<parameter key="sylius.active_promotions_by_channel_provider.class">Sylius\Component\Core\Provider\ActivePromotionsByChannelProvider</parameter>
|
||||||
|
|
||||||
|
|
@ -413,10 +412,6 @@
|
||||||
<tag name="kernel.event_listener" event="sylius.user.security.implicit_login" method="recalculateCartWhileLogin" />
|
<tag name="kernel.event_listener" event="sylius.user.security.implicit_login" method="recalculateCartWhileLogin" />
|
||||||
<tag name="kernel.event_listener" event="security.interactive_login" method="recalculateCartWhileLogin" />
|
<tag name="kernel.event_listener" event="security.interactive_login" method="recalculateCartWhileLogin" />
|
||||||
</service>
|
</service>
|
||||||
<service id="sylius.listener.store_order_id" class="%sylius.listener.store_order_id.class%">
|
|
||||||
<argument type="service" id="session" />
|
|
||||||
<tag name="kernel.event_listener" event="sylius.order.post_summary" method="setOrderId" />
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<service id="sylius.active_promotions_by_channel_provider" class="%sylius.active_promotions_by_channel_provider.class%">
|
<service id="sylius.active_promotions_by_channel_provider" class="%sylius.active_promotions_by_channel_provider.class%">
|
||||||
<argument type="service" id="sylius.repository.promotion" />
|
<argument type="service" id="sylius.repository.promotion" />
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ class SyliusShopExtension extends Extension
|
||||||
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||||
|
|
||||||
$loader->load('controller.xml');
|
$loader->load('controller.xml');
|
||||||
|
$loader->load('listeners.xml');
|
||||||
$loader->load('menu.xml');
|
$loader->load('menu.xml');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Sylius\Bundle\CoreBundle\EventListener;
|
namespace Sylius\Bundle\ShopBundle\EventListener;
|
||||||
|
|
||||||
use Sylius\Component\Core\Model\OrderInterface;
|
use Sylius\Component\Core\Model\OrderInterface;
|
||||||
use Symfony\Component\EventDispatcher\GenericEvent;
|
use Symfony\Component\EventDispatcher\GenericEvent;
|
||||||
|
|
@ -19,7 +19,7 @@ use Webmozart\Assert\Assert;
|
||||||
/**
|
/**
|
||||||
* @author Arkadiusz Krakowiak <arkadiusz.krakowiak@lakion.com>
|
* @author Arkadiusz Krakowiak <arkadiusz.krakowiak@lakion.com>
|
||||||
*/
|
*/
|
||||||
class StoreOrderIdListener
|
class CheckoutCompleteListener
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var SessionInterface
|
* @var SessionInterface
|
||||||
|
|
@ -35,9 +35,9 @@ class StoreOrderIdListener
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param GenericEvent $event
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function setOrderId(GenericEvent $event)
|
public function onCheckoutComplete(GenericEvent $event)
|
||||||
{
|
{
|
||||||
/** @var OrderInterface $order */
|
/** @var OrderInterface $order */
|
||||||
$order = $event->getSubject();
|
$order = $event->getSubject();
|
||||||
29
src/Sylius/Bundle/ShopBundle/Resources/config/listeners.xml
Normal file
29
src/Sylius/Bundle/ShopBundle/Resources/config/listeners.xml
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
|
||||||
|
This file is part of the Sylius package.
|
||||||
|
|
||||||
|
(c) Paweł Jędrzejewski
|
||||||
|
|
||||||
|
For the full copyright and license information, please view the LICENSE
|
||||||
|
file that was distributed with this source code.
|
||||||
|
|
||||||
|
-->
|
||||||
|
|
||||||
|
<container xmlns="http://symfony.com/schema/dic/services"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://symfony.com/schema/dic/services
|
||||||
|
http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||||
|
|
||||||
|
<parameters>
|
||||||
|
<parameter key="sylius.listener.checkout_complete.class">Sylius\Bundle\ShopBundle\EventListener\CheckoutCompleteListener</parameter>
|
||||||
|
</parameters>
|
||||||
|
|
||||||
|
<services>
|
||||||
|
<service id="sylius.listener.checkout_complete" class="%sylius.listener.checkout_complete.class%">
|
||||||
|
<argument type="service" id="session"/>
|
||||||
|
<tag name="kernel.event_listener" event="sylius.order.post_summary" method="onCheckoutComplete" />
|
||||||
|
</service>
|
||||||
|
</services>
|
||||||
|
</container>
|
||||||
|
|
@ -9,22 +9,22 @@
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace spec\Sylius\Bundle\CoreBundle\EventListener;
|
namespace spec\Sylius\Bundle\ShopBundle\EventListener;
|
||||||
|
|
||||||
use PhpSpec\ObjectBehavior;
|
use PhpSpec\ObjectBehavior;
|
||||||
use Prophecy\Argument;
|
use Prophecy\Argument;
|
||||||
use Sylius\Bundle\CoreBundle\EventListener\StoreOrderIdListener;
|
use Sylius\Bundle\ShopBundle\EventListener\CheckoutCompleteListener;
|
||||||
use Sylius\Component\Addressing\Model\CountryInterface;
|
use Sylius\Component\Addressing\Model\CountryInterface;
|
||||||
use Sylius\Component\Core\Model\OrderInterface;
|
use Sylius\Component\Core\Model\OrderInterface;
|
||||||
use Symfony\Component\EventDispatcher\GenericEvent;
|
use Symfony\Component\EventDispatcher\GenericEvent;
|
||||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @mixin StoreOrderIdListener
|
* @mixin CheckoutCompleteListener
|
||||||
*
|
*
|
||||||
* @author Arkadiusz Krakowiak <arkadiusz.krakowiak@lakion.com>
|
* @author Arkadiusz Krakowiak <arkadiusz.krakowiak@lakion.com>
|
||||||
*/
|
*/
|
||||||
class StoreOrderIdListenerSpec extends ObjectBehavior
|
class CheckoutCompleteListenerSpec extends ObjectBehavior
|
||||||
{
|
{
|
||||||
function let(SessionInterface $session)
|
function let(SessionInterface $session)
|
||||||
{
|
{
|
||||||
|
|
@ -33,7 +33,7 @@ class StoreOrderIdListenerSpec extends ObjectBehavior
|
||||||
|
|
||||||
function it_is_initializable()
|
function it_is_initializable()
|
||||||
{
|
{
|
||||||
$this->shouldHaveType('Sylius\Bundle\CoreBundle\EventListener\StoreOrderIdListener');
|
$this->shouldHaveType('Sylius\Bundle\ShopBundle\EventListener\CheckoutCompleteListener');
|
||||||
}
|
}
|
||||||
|
|
||||||
function it_sets_order_id_in_session(SessionInterface $session, OrderInterface $order, GenericEvent $event)
|
function it_sets_order_id_in_session(SessionInterface $session, OrderInterface $order, GenericEvent $event)
|
||||||
|
|
@ -42,7 +42,7 @@ class StoreOrderIdListenerSpec extends ObjectBehavior
|
||||||
$order->getId()->willReturn(1);
|
$order->getId()->willReturn(1);
|
||||||
$session->set('sylius_order_id', 1)->shouldBeCalled();
|
$session->set('sylius_order_id', 1)->shouldBeCalled();
|
||||||
|
|
||||||
$this->setOrderId($event);
|
$this->onCheckoutComplete($event);
|
||||||
}
|
}
|
||||||
|
|
||||||
function it_throws_invalid_argument_exception_if_subject_is_not_an_order(
|
function it_throws_invalid_argument_exception_if_subject_is_not_an_order(
|
||||||
|
|
@ -53,6 +53,6 @@ class StoreOrderIdListenerSpec extends ObjectBehavior
|
||||||
$event->getSubject()->willReturn($country);
|
$event->getSubject()->willReturn($country);
|
||||||
$session->set('sylius_order_id', Argument::any())->shouldNotBeCalled();
|
$session->set('sylius_order_id', Argument::any())->shouldNotBeCalled();
|
||||||
|
|
||||||
$this->shouldThrow(\InvalidArgumentException::class)->during('setOrderId', [$event]);
|
$this->shouldThrow(\InvalidArgumentException::class)->during('onCheckoutComplete', [$event]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Reference in a new issue