![]() 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/old/vendor/magento/module-wishlist/Plugin/Model/ResourceModel/ |
<?php /** * * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\Wishlist\Plugin\Model\ResourceModel; use Magento\Catalog\Api\Data\ProductInterface; use Magento\Catalog\Model\ResourceModel\Product as ProductResourceModel; use Magento\Framework\Exception\LocalizedException; use Magento\Wishlist\Model\WishlistCleaner; /** * Cleans up wishlist items referencing the product being deleted */ class Product { /** * @var WishlistCleaner */ private $wishlistCleaner; /** * @param WishlistCleaner $wishlistCleaner */ public function __construct( WishlistCleaner $wishlistCleaner ) { $this->wishlistCleaner = $wishlistCleaner; } /** * Cleans up wishlist items referencing the product being deleted * * @param ProductResourceModel $productResourceModel * @param mixed $product * @return void * @throws LocalizedException * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function beforeDelete( ProductResourceModel $productResourceModel, $product ) { if ($product instanceof ProductInterface) { $this->wishlistCleaner->execute($product); } } }