Skip to content

Commit 842c92f

Browse files
author
Alexander Paliarush
committed
MAGETWO-51366: Constants must not be used as first argument of translation function
1 parent 2087543 commit 842c92f

File tree

63 files changed

+251
-142
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+251
-142
lines changed

app/code/Magento/Bundle/Model/Option/Validator.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66
namespace Magento\Bundle\Model\Option;
77

8-
use Magento\Framework\Exception\InputException;
98
use Magento\Framework\Validator\NotEmpty;
109
use Magento\Framework\Validator\NotEmptyFactory;
1110
use Zend_Validate_Exception;
@@ -52,7 +51,7 @@ protected function validateRequiredFields($value)
5251
];
5352
foreach ($requiredFields as $requiredField => $requiredValue) {
5453
if (!$this->notEmpty->isValid(trim($requiredValue))) {
55-
$messages[$requiredField] = __(InputException::REQUIRED_FIELD, ['fieldName' => $requiredField]);
54+
$messages[$requiredField] = __('%fieldName is a required field.', ['fieldName' => $requiredField]);
5655
}
5756
}
5857
$this->_addMessages($messages);

app/code/Magento/Customer/Model/AccountManagement.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ public function initiatePasswordReset($email, $template, $websiteId = null)
509509
default:
510510
throw new InputException(
511511
__(
512-
InputException::INVALID_FIELD_VALUE,
512+
'Invalid value of "%value" provided for the %fieldName field.',
513513
['value' => $template, 'fieldName' => 'email type']
514514
)
515515
);
@@ -909,11 +909,11 @@ private function validateResetPasswordToken($customerId, $resetPasswordLinkToken
909909
{
910910
if (empty($customerId) || $customerId < 0) {
911911
$params = ['value' => $customerId, 'fieldName' => 'customerId'];
912-
throw new InputException(__(InputException::INVALID_FIELD_VALUE, $params));
912+
throw new InputException(__('Invalid value of "%value" provided for the %fieldName field.', $params));
913913
}
914914
if (!is_string($resetPasswordLinkToken) || empty($resetPasswordLinkToken)) {
915915
$params = ['fieldName' => 'resetPasswordLinkToken'];
916-
throw new InputException(__(InputException::REQUIRED_FIELD, $params));
916+
throw new InputException(__('%fieldName is a required field.', $params));
917917
}
918918

919919
$customerSecureData = $this->customerRegistry->retrieveSecureData($customerId);
@@ -1164,7 +1164,7 @@ public function changeResetPasswordLinkToken($customer, $passwordLinkToken)
11641164
if (!is_string($passwordLinkToken) || empty($passwordLinkToken)) {
11651165
throw new InputException(
11661166
__(
1167-
InputException::INVALID_FIELD_VALUE,
1167+
'Invalid value of "%value" provided for the %fieldName field.',
11681168
['value' => $passwordLinkToken, 'fieldName' => 'password reset token']
11691169
)
11701170
);

app/code/Magento/Customer/Model/CustomerRegistry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function retrieveByEmail($customerEmail, $websiteId = null)
120120
// customer does not exist
121121
throw new NoSuchEntityException(
122122
__(
123-
NoSuchEntityException::MESSAGE_DOUBLE_FIELDS,
123+
'No such entity with %fieldName = %fieldValue, %field2Name = %field2Value',
124124
[
125125
'fieldName' => 'email',
126126
'fieldValue' => $customerEmail,

app/code/Magento/Customer/Model/Metadata/AddressMetadata.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function getAttributeMetadata($attributeCode)
7979
} else {
8080
throw new NoSuchEntityException(
8181
__(
82-
NoSuchEntityException::MESSAGE_DOUBLE_FIELDS,
82+
'No such entity with %fieldName = %fieldValue, %field2Name = %field2Value',
8383
[
8484
'fieldName' => 'entityType',
8585
'fieldValue' => AddressMetadataInterface::ENTITY_TYPE_ADDRESS,

app/code/Magento/Customer/Model/Metadata/AttributeResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function getModelByAttribute($entityType, AttributeMetadataInterface $att
4646
} else {
4747
throw new NoSuchEntityException(
4848
__(
49-
NoSuchEntityException::MESSAGE_DOUBLE_FIELDS,
49+
'No such entity with %fieldName = %fieldValue, %field2Name = %field2Value',
5050
[
5151
'fieldName' => 'entityType',
5252
'fieldValue' => $entityType,

app/code/Magento/Customer/Model/Metadata/CustomerMetadata.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function getAttributeMetadata($attributeCode)
7979
} else {
8080
throw new NoSuchEntityException(
8181
__(
82-
NoSuchEntityException::MESSAGE_DOUBLE_FIELDS,
82+
'No such entity with %fieldName = %fieldValue, %field2Name = %field2Value',
8383
[
8484
'fieldName' => 'entityType',
8585
'fieldValue' => self::ENTITY_TYPE_CUSTOMER,

app/code/Magento/Customer/Model/ResourceModel/AddressRepository.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -257,48 +257,48 @@ private function _validate(CustomerAddressModel $customerAddressModel)
257257
}
258258

259259
if (!\Zend_Validate::is($customerAddressModel->getFirstname(), 'NotEmpty')) {
260-
$exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'firstname']));
260+
$exception->addError(__('%fieldName is a required field.', ['fieldName' => 'firstname']));
261261
}
262262

263263
if (!\Zend_Validate::is($customerAddressModel->getLastname(), 'NotEmpty')) {
264-
$exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'lastname']));
264+
$exception->addError(__('%fieldName is a required field.', ['fieldName' => 'lastname']));
265265
}
266266

267267
if (!\Zend_Validate::is($customerAddressModel->getStreetLine(1), 'NotEmpty')) {
268-
$exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'street']));
268+
$exception->addError(__('%fieldName is a required field.', ['fieldName' => 'street']));
269269
}
270270

271271
if (!\Zend_Validate::is($customerAddressModel->getCity(), 'NotEmpty')) {
272-
$exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'city']));
272+
$exception->addError(__('%fieldName is a required field.', ['fieldName' => 'city']));
273273
}
274274

275275
if (!\Zend_Validate::is($customerAddressModel->getTelephone(), 'NotEmpty')) {
276-
$exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'telephone']));
276+
$exception->addError(__('%fieldName is a required field.', ['fieldName' => 'telephone']));
277277
}
278278

279279
$havingOptionalZip = $this->directoryData->getCountriesWithOptionalZip();
280280
if (!in_array($customerAddressModel->getCountryId(), $havingOptionalZip)
281281
&& !\Zend_Validate::is($customerAddressModel->getPostcode(), 'NotEmpty')
282282
) {
283-
$exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'postcode']));
283+
$exception->addError(__('%fieldName is a required field.', ['fieldName' => 'postcode']));
284284
}
285285

286286
if (!\Zend_Validate::is($customerAddressModel->getCountryId(), 'NotEmpty')) {
287-
$exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'countryId']));
287+
$exception->addError(__('%fieldName is a required field.', ['fieldName' => 'countryId']));
288288
}
289289

290290
if ($this->directoryData->isRegionRequired($customerAddressModel->getCountryId())) {
291291
$regionCollection = $customerAddressModel->getCountryModel()->getRegionCollection();
292292
if (!$regionCollection->count() && empty($customerAddressModel->getRegion())) {
293-
$exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'region']));
293+
$exception->addError(__('%fieldName is a required field.', ['fieldName' => 'region']));
294294
} elseif (
295295
$regionCollection->count()
296296
&& !in_array(
297297
$customerAddressModel->getRegionId(),
298298
array_column($regionCollection->getData(), 'region_id')
299299
)
300300
) {
301-
$exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'regionId']));
301+
$exception->addError(__('%fieldName is a required field.', ['fieldName' => 'regionId']));
302302
}
303303
}
304304
return $exception;

app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
namespace Magento\Customer\Model\ResourceModel;
88

99
use Magento\Customer\Api\CustomerMetadataInterface;
10-
use Magento\Customer\Model\Data\CustomerSecure;
1110
use Magento\Framework\Api\DataObjectHelper;
1211
use Magento\Framework\Api\ImageProcessorInterface;
1312
use Magento\Framework\Api\SearchCriteriaInterface;
@@ -333,11 +332,11 @@ private function validate(\Magento\Customer\Api\Data\CustomerInterface $customer
333332
{
334333
$exception = new InputException();
335334
if (!\Zend_Validate::is(trim($customer->getFirstname()), 'NotEmpty')) {
336-
$exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'firstname']));
335+
$exception->addError(__('%fieldName is a required field.', ['fieldName' => 'firstname']));
337336
}
338337

339338
if (!\Zend_Validate::is(trim($customer->getLastname()), 'NotEmpty')) {
340-
$exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'lastname']));
339+
$exception->addError(__('%fieldName is a required field.', ['fieldName' => 'lastname']));
341340
}
342341

343342
$isEmailAddress = \Zend_Validate::is(
@@ -348,25 +347,25 @@ private function validate(\Magento\Customer\Api\Data\CustomerInterface $customer
348347
if (!$isEmailAddress) {
349348
$exception->addError(
350349
__(
351-
InputException::INVALID_FIELD_VALUE,
350+
'Invalid value of "%value" provided for the %fieldName field.',
352351
['fieldName' => 'email', 'value' => $customer->getEmail()]
353352
)
354353
);
355354
}
356355

357356
$dob = $this->getAttributeMetadata('dob');
358357
if ($dob !== null && $dob->isRequired() && '' == trim($customer->getDob())) {
359-
$exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'dob']));
358+
$exception->addError(__('%fieldName is a required field.', ['fieldName' => 'dob']));
360359
}
361360

362361
$taxvat = $this->getAttributeMetadata('taxvat');
363362
if ($taxvat !== null && $taxvat->isRequired() && '' == trim($customer->getTaxvat())) {
364-
$exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'taxvat']));
363+
$exception->addError(__('%fieldName is a required field.', ['fieldName' => 'taxvat']));
365364
}
366365

367366
$gender = $this->getAttributeMetadata('gender');
368367
if ($gender !== null && $gender->isRequired() && '' == trim($customer->getGender())) {
369-
$exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'gender']));
368+
$exception->addError(__('%fieldName is a required field.', ['fieldName' => 'gender']));
370369
}
371370

372371
if ($exception->wasErrorAdded()) {

app/code/Magento/Customer/Model/ResourceModel/GroupRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ private function _validate($group)
317317
{
318318
$exception = new InputException();
319319
if (!\Zend_Validate::is($group->getCode(), 'NotEmpty')) {
320-
$exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'code']));
320+
$exception->addError(__('%fieldName is a required field.', ['fieldName' => 'code']));
321321
}
322322

323323
if ($exception->wasErrorAdded()) {

app/code/Magento/Customer/Test/Unit/Block/Account/Dashboard/InfoTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public function testGetCustomerException()
138138
->will(
139139
$this->throwException(new NoSuchEntityException(
140140
__(
141-
NoSuchEntityException::MESSAGE_SINGLE_FIELD,
141+
'No such entity with %fieldName = %fieldValue',
142142
['fieldName' => 'customerId', 'fieldValue' => 1]
143143
)
144144
))

0 commit comments

Comments
 (0)