* @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\Supplier\CommandHandler; use PrestaShop\PrestaShop\Core\Domain\Supplier\Command\DeleteSupplierCommand; use PrestaShop\PrestaShop\Core\Domain\Supplier\CommandHandler\DeleteSupplierHandlerInterface; use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\CannotDeleteSupplierException; use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\SupplierException; /** * Class DeleteSupplierHandler is responsible for deleting the supplier. */ final class DeleteSupplierHandler extends AbstractDeleteSupplierHandler implements DeleteSupplierHandlerInterface { /** * {@inheritdoc} * * @throws SupplierException */ public function handle(DeleteSupplierCommand $command) { $supplierId = $command->getSupplierId(); try { $this->removeSupplier($supplierId); } catch (SupplierException $e) { if (SupplierException::class === get_class($e)) { throw new CannotDeleteSupplierException(sprintf('Cannot delete Supplier object with id "%s".', $supplierId->getValue()), CannotDeleteSupplierException::FAILED_DELETE); } throw $e; } } }