init
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\TestModuleQuoteTotalsObserver\Model;
|
||||
|
||||
class Config
|
||||
{
|
||||
private $active = false;
|
||||
|
||||
public function enableObserver()
|
||||
{
|
||||
$this->active = true;
|
||||
}
|
||||
|
||||
public function disableObserver()
|
||||
{
|
||||
$this->active = false;
|
||||
}
|
||||
|
||||
public function isActive()
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\TestModuleQuoteTotalsObserver\Observer;
|
||||
|
||||
use Magento\Framework\Event\Observer;
|
||||
use Magento\Framework\Event\ObserverInterface;
|
||||
|
||||
class AfterCollectTotals implements ObserverInterface
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Checkout\Model\Session
|
||||
*/
|
||||
private $session;
|
||||
|
||||
/**
|
||||
* @var \Magento\TestModuleQuoteTotalsObserver\Model\Config
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* AfterCollectTotals constructor.
|
||||
* @param \Magento\Checkout\Model\Session $messageManager
|
||||
* @param \Magento\TestModuleQuoteTotalsObserver\Model\Config $config
|
||||
*/
|
||||
public function __construct(
|
||||
\Magento\Checkout\Model\Session $messageManager,
|
||||
\Magento\TestModuleQuoteTotalsObserver\Model\Config $config
|
||||
) {
|
||||
$this->config = $config;
|
||||
$this->session = $messageManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Observer $observer
|
||||
* @return void
|
||||
*/
|
||||
public function execute(\Magento\Framework\Event\Observer $observer)
|
||||
{
|
||||
$observer->getEvent();
|
||||
if ($this->config->isActive()) {
|
||||
$this->session->getQuote();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
|
||||
<event name="sales_quote_collect_totals_after">
|
||||
<observer name="test_module_quote_totals_observer_after_collect_totals" instance="Magento\TestModuleQuoteTotalsObserver\Observer\AfterCollectTotals" />
|
||||
</event>
|
||||
</config>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
|
||||
<module name="Magento_TestModuleQuoteTotalsObserver" active="true">
|
||||
</module>
|
||||
</config>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
use Magento\Framework\Component\ComponentRegistrar;
|
||||
|
||||
$registrar = new ComponentRegistrar();
|
||||
if ($registrar->getPath(ComponentRegistrar::MODULE, 'Magento_TestModuleQuoteTotalsObserver') === null) {
|
||||
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_TestModuleQuoteTotalsObserver', __DIR__);
|
||||
}
|
||||
Reference in New Issue
Block a user