* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ declare(strict_types=1); namespace PrestaShop\PrestaShop\Adapter\Product\Attachment\CommandHandler; use PrestaShop\PrestaShop\Adapter\Product\Update\ProductAttachmentUpdater; use PrestaShop\PrestaShop\Core\Domain\Product\Attachment\Command\RemoveAllAssociatedProductAttachmentsCommand; use PrestaShop\PrestaShop\Core\Domain\Product\Attachment\CommandHandler\RemoveAllAssociatedProductAttachmentsHandlerInterface; /** * Removes all product-attachment associations for given product */ final class RemoveAllAssociatedProductAttachmentsHandler implements RemoveAllAssociatedProductAttachmentsHandlerInterface { /** * @var ProductAttachmentUpdater */ private $productAttachmentUpdater; /** * @param ProductAttachmentUpdater $productAttachmentUpdater */ public function __construct( ProductAttachmentUpdater $productAttachmentUpdater ) { $this->productAttachmentUpdater = $productAttachmentUpdater; } /** * {@inheritdoc} */ public function handle(RemoveAllAssociatedProductAttachmentsCommand $command): void { $this->productAttachmentUpdater->setAttachments($command->getProductId(), []); } }