* @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\DeleteCustomerCommand; use PrestaShop\PrestaShop\Core\Domain\Customer\CommandHandler\DeleteCustomerHandlerInterface; /** * Handles delete customer command. * * @internal */ final class DeleteCustomerHandler extends AbstractCustomerHandler implements DeleteCustomerHandlerInterface { /** * {@inheritdoc} */ public function handle(DeleteCustomerCommand $command) { $customerId = $command->getCustomerId(); $customer = new Customer($customerId->getValue()); $this->assertCustomerWasFound($customerId, $customer); if ($command->getDeleteMethod()->isAllowedToRegisterAfterDelete()) { $customer->delete(); return; } // soft delete customer // in order to forbid signing in again $customer->deleted = true; $customer->update(); } }