forked from mageplaza/magento-2-webhook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBeforeSave.php
62 lines (57 loc) · 1.31 KB
/
BeforeSave.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_Webhook
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/
namespace Mageplaza\Webhook\Observer;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
use Mageplaza\Webhook\Helper\Data;
/**
* Class BeforeSave
* @package Mageplaza\Webhook\Observer
*/
class BeforeSave implements ObserverInterface
{
/**
* @var Data
*/
protected $helper;
/**
* BeforeSave constructor.
*
* @param Data $helper
*/
public function __construct(Data $helper)
{
$this->helper = $helper;
}
/**
* @param Observer $observer
*/
public function execute(Observer $observer)
{
if (!$this->helper->isEnabled()) {
return;
}
$item = $observer->getDataObject();
if ($item->isObjectNew()) {
$item->setMpNew(1);
}
}
}