* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\PrestaShop\Adapter\Customer\CommandHandler; use Customer; use PrestaShop\PrestaShop\Core\Domain\Customer\Command\BulkDeleteCustomerCommand; use PrestaShop\PrestaShop\Core\Domain\Customer\CommandHandler\BulkDeleteCustomerHandlerInterface; /** * Handles command that deletes customers in bulk action. * * @internal */ final class BulkDeleteCustomerHandler extends AbstractCustomerHandler implements BulkDeleteCustomerHandlerInterface { /** * {@inheritdoc} */ public function handle(BulkDeleteCustomerCommand $command) { foreach ($command->getCustomerIds() as $customerId) { $customer = new Customer($customerId->getValue()); $this->assertCustomerWasFound($customerId, $customer); if ($command->getDeleteMethod()->isAllowedToRegisterAfterDelete()) { $customer->delete(); continue; } $customer->deleted = true; $customer->update(); } } }