![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/cartforge.co/app/code/Webkul/PrivateShop/Model/Plugin/ |
<?php /** * Webkul Software * * @category Webkul * @package Webkul_PrivateShop * @author Webkul Software Private Limited * @copyright Webkul Software Private Limited (https://webkul.com) * @license https://store.webkul.com/license.html */ namespace Webkul\PrivateShop\Model\Plugin; use Magento\Framework\App\State; use Magento\Framework\App\RequestInterface; use Magento\Customer\Api\CustomerRepositoryInterface; use Magento\Customer\Api\Data\CustomerInterface; /** * Class CustomerRepositoryPlugin * Webkul\PrivateShop\Model\Plugin */ class CustomerRepositoryPlugin { /** * @var State */ private $state; /** * @var RequestInterface */ private $request; /** * @var \Magento\Framework\Serialize\Serializer\Json */ protected $jsonSerializer; /** * * @param State $state * @param RequestInterface $request * @param \Magento\Framework\Serialize\Serializer\Json $jsonSerializer */ public function __construct( State $state, RequestInterface $request, \Magento\Framework\Serialize\Serializer\Json $jsonSerializer ) { $this->state = $state; $this->request = $request; $this->jsonSerializer = $jsonSerializer; } /** * This is BeforeSave * * @param \Magento\Customer\Model\ResourceModel\CustomerRepository $subject * @param \Magento\Customer\Api\Data\CustomerInterface $customer * @param CustomerRepositoryPlugin $passwordHash * @return array * @throws InputException * @throws \Magento\Framework\Exception\LocalizedException */ public function beforeSave( CustomerRepositoryInterface $subject, CustomerInterface $customer, $passwordHash = null ) { $customerDataOriginal = $groupOriginal = null; $groupAttribute = $customer->getCustomAttribute('customer_private_group'); $isGroupsData = isset($this->request->getParam('private_shop')['is_groups_data']) ?? $this->request->getParam('private_shop')['is_groups_data'] :: null; if ($this->state->getAreaCode() == 'adminhtml' && $this->request->getParam('private_shop') && $isGroupsData != null ) { $groups = $this->request->getParam('private_shop')['data'] ?? null; if ($groups && $this->request->getParam('private_shop')['is_groups_data'] == 'true') { $groups = $this->jsonSerializer->serialize($groups); $customer->setCustomAttribute( 'customer_private_group', $groups ); } elseif ($this->request->getParam('private_shop')['is_groups_data'] == 'false') { $customer->setCustomAttribute( 'customer_private_group', '' ); } } return [$customer, $passwordHash]; } }