* @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\SetRequiredFieldsForCustomerCommand; use PrestaShop\PrestaShop\Core\Domain\Customer\CommandHandler\SetRequiredFieldsForCustomerHandlerInterface; use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CannotSetRequiredFieldsForCustomerException; /** * Handles command which sets required fields for customer. * * @internal */ final class SetRequiredFieldsForCustomerHandler implements SetRequiredFieldsForCustomerHandlerInterface { /** * {@inheritdoc} */ public function handle(SetRequiredFieldsForCustomerCommand $command) { $customer = new Customer(); if (!$customer->addFieldsRequiredDatabase($command->getRequiredFields())) { throw new CannotSetRequiredFieldsForCustomerException(sprintf('Cannot set "%s" required fields for customer', implode(',', $command->getRequiredFields()))); } } }