Unify quotes around IDs in error messages

[MAILPOET-5729]
This commit is contained in:
 Ján Mikláš
2023-11-22 12:15:24 +01:00
committed by David Remer
parent ecaaaaa729
commit dfe6076599
3 changed files with 10 additions and 10 deletions

View File

@@ -395,30 +395,30 @@ class Subscribers {
if ($foundSegment->getType() === SegmentEntity::TYPE_WP_USERS) { if ($foundSegment->getType() === SegmentEntity::TYPE_WP_USERS) {
if ($context === self::CONTEXT_SUBSCRIBE) { if ($context === self::CONTEXT_SUBSCRIBE) {
// translators: %d is the ID of the segment // translators: %d is the ID of the segment
$message = __("Can't subscribe to a WordPress Users list with ID %d.", 'mailpoet'); $message = __("Can't subscribe to a WordPress Users list with ID '%d'.", 'mailpoet');
} else { } else {
// translators: %d is the ID of the segment // translators: %d is the ID of the segment
$message = __("Can't unsubscribe from a WordPress Users list with ID %d.", 'mailpoet'); $message = __("Can't unsubscribe from a WordPress Users list with ID '%d'.", 'mailpoet');
} }
throw new APIException(sprintf($message, $foundSegment->getId()), APIException::SUBSCRIBING_TO_WP_LIST_NOT_ALLOWED); throw new APIException(sprintf($message, $foundSegment->getId()), APIException::SUBSCRIBING_TO_WP_LIST_NOT_ALLOWED);
} }
if ($foundSegment->getType() === SegmentEntity::TYPE_WC_USERS) { if ($foundSegment->getType() === SegmentEntity::TYPE_WC_USERS) {
if ($context === self::CONTEXT_SUBSCRIBE) { if ($context === self::CONTEXT_SUBSCRIBE) {
// translators: %d is the ID of the segment // translators: %d is the ID of the segment
$message = __("Can't subscribe to a WooCommerce Customers list with ID %d.", 'mailpoet'); $message = __("Can't subscribe to a WooCommerce Customers list with ID '%d'.", 'mailpoet');
} else { } else {
// translators: %d is the ID of the segment // translators: %d is the ID of the segment
$message = __("Can't unsubscribe from a WooCommerce Customers list with ID %d.", 'mailpoet'); $message = __("Can't unsubscribe from a WooCommerce Customers list with ID '%d'.", 'mailpoet');
} }
throw new APIException(sprintf($message, $foundSegment->getId()), APIException::SUBSCRIBING_TO_WC_LIST_NOT_ALLOWED); throw new APIException(sprintf($message, $foundSegment->getId()), APIException::SUBSCRIBING_TO_WC_LIST_NOT_ALLOWED);
} }
if ($foundSegment->getType() !== SegmentEntity::TYPE_DEFAULT) { if ($foundSegment->getType() !== SegmentEntity::TYPE_DEFAULT) {
if ($context === self::CONTEXT_SUBSCRIBE) { if ($context === self::CONTEXT_SUBSCRIBE) {
// translators: %d is the ID of the segment // translators: %d is the ID of the segment
$message = __("Can't subscribe to a list with ID %d.", 'mailpoet'); $message = __("Can't subscribe to a list with ID '%d'.", 'mailpoet');
} else { } else {
// translators: %d is the ID of the segment // translators: %d is the ID of the segment
$message = __("Can't unsubscribe from a list with ID %d.", 'mailpoet'); $message = __("Can't unsubscribe from a list with ID '%d'.", 'mailpoet');
} }
throw new APIException(sprintf($message, $foundSegment->getId()), APIException::SUBSCRIBING_TO_LIST_NOT_ALLOWED); throw new APIException(sprintf($message, $foundSegment->getId()), APIException::SUBSCRIBING_TO_LIST_NOT_ALLOWED);
} }
@@ -430,7 +430,7 @@ class Subscribers {
$missingIds = array_values(array_diff($listIds, $foundSegmentsIds)); $missingIds = array_values(array_diff($listIds, $foundSegmentsIds));
$exception = sprintf( $exception = sprintf(
// translators: %s is the count of lists // translators: %s is the count of lists
_n('List with ID %s does not exist.', 'Lists with IDs %s do not exist.', count($missingIds), 'mailpoet'), _n("List with ID '%s' does not exist.", "Lists with IDs '%s' do not exist.", count($missingIds), 'mailpoet'),
implode(', ', $missingIds) implode(', ', $missingIds)
); );
throw new APIException(sprintf($exception, implode(', ', $missingIds)), APIException::LIST_NOT_EXISTS); throw new APIException(sprintf($exception, implode(', ', $missingIds)), APIException::LIST_NOT_EXISTS);

View File

@@ -56,7 +56,7 @@ class NewsletterLinkSubject implements Subject {
$linkId = $subjectData->getArgs()['link_id']; $linkId = $subjectData->getArgs()['link_id'];
$linkEntity = $this->newsletterLinkRepository->findOneById($linkId); $linkEntity = $this->newsletterLinkRepository->findOneById($linkId);
if (!$linkEntity) { if (!$linkEntity) {
throw NotFoundException::create()->withMessage(sprintf('Email link with ID %d not found', $linkId)); throw NotFoundException::create()->withMessage(sprintf("Email link with ID '%d' not found", $linkId));
} }
return new NewsletterLinkPayload($linkEntity); return new NewsletterLinkPayload($linkEntity);

View File

@@ -153,10 +153,10 @@ class SegmentsRepository extends Repository {
try { try {
$dynamicSegment = $this->findOneById($id); $dynamicSegment = $this->findOneById($id);
if (!$dynamicSegment instanceof SegmentEntity) { if (!$dynamicSegment instanceof SegmentEntity) {
throw InvalidStateException::create()->withMessage(sprintf("Could not find segment with ID %s.", $id)); throw InvalidStateException::create()->withMessage(sprintf("Could not find segment with ID '%s'.", $id));
} }
if ($dynamicSegment->getType() !== SegmentEntity::TYPE_DYNAMIC) { if ($dynamicSegment->getType() !== SegmentEntity::TYPE_DYNAMIC) {
throw InvalidStateException::create()->withMessage(sprintf("Segment with ID %s is not a dynamic segment. Its type is %s.", $id, $dynamicSegment->getType())); throw InvalidStateException::create()->withMessage(sprintf("Segment with ID '%s' is not a dynamic segment. Its type is %s.", $id, $dynamicSegment->getType()));
} }
} catch (InvalidStateException $exception) { } catch (InvalidStateException $exception) {
$this->loggerFactory->getLogger(LoggerFactory::TOPIC_SEGMENTS)->error(sprintf("Could not verify existence of dynamic segment: %s", $exception->getMessage())); $this->loggerFactory->getLogger(LoggerFactory::TOPIC_SEGMENTS)->error(sprintf("Could not verify existence of dynamic segment: %s", $exception->getMessage()));