本文整理汇总了PHP中Magento\Directory\Helper\Data::getCountriesWithOptionalZip方法的典型用法代码示例。如果您正苦于以下问题:PHP Data::getCountriesWithOptionalZip方法的具体用法?PHP Data::getCountriesWithOptionalZip怎么用?PHP Data::getCountriesWithOptionalZip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Directory\Helper\Data
的用法示例。
在下文中一共展示了Data::getCountriesWithOptionalZip方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateValue
/**
* @param string $value
* @return true|string[]
*/
public function validateValue($value)
{
$countryId = $this->getExtractedData('country_id');
$optionalZip = $this->_directoryData->getCountriesWithOptionalZip();
if (!in_array($countryId, $optionalZip)) {
return parent::validateValue($value);
}
return true;
}
示例2: validate
/**
* Validate address attribute values
*
* @return bool|array
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function validate()
{
$errors = [];
if (!\Zend_Validate::is($this->getFirstname(), 'NotEmpty')) {
$errors[] = __('Please enter the first name.');
}
if (!\Zend_Validate::is($this->getLastname(), 'NotEmpty')) {
$errors[] = __('Please enter the last name.');
}
if (!\Zend_Validate::is($this->getStreetLine(1), 'NotEmpty')) {
$errors[] = __('Please enter the street.');
}
if (!\Zend_Validate::is($this->getCity(), 'NotEmpty')) {
$errors[] = __('Please enter the city.');
}
if (!\Zend_Validate::is($this->getTelephone(), 'NotEmpty')) {
$errors[] = __('Please enter the phone number.');
}
$_havingOptionalZip = $this->_directoryData->getCountriesWithOptionalZip();
if (!in_array($this->getCountryId(), $_havingOptionalZip) && !\Zend_Validate::is($this->getPostcode(), 'NotEmpty')) {
$errors[] = __('Please enter the zip/postal code.');
}
if (!\Zend_Validate::is($this->getCountryId(), 'NotEmpty')) {
$errors[] = __('Please enter the country.');
}
if ($this->getCountryModel()->getRegionCollection()->getSize() && !\Zend_Validate::is($this->getRegionId(), 'NotEmpty') && $this->_directoryData->isRegionRequired($this->getCountryId())) {
$errors[] = __('Please enter the state/province.');
}
if (empty($errors) || $this->getShouldIgnoreValidation()) {
return true;
}
return $errors;
}
示例3: _validate
/**
* Validate Customer Addresses attribute values.
*
* @param CustomerAddressModel $customerAddressModel the model to validate
* @return InputException
*
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
private function _validate(CustomerAddressModel $customerAddressModel)
{
$exception = new InputException();
if ($customerAddressModel->getShouldIgnoreValidation()) {
return $exception;
}
if (!\Zend_Validate::is($customerAddressModel->getFirstname(), 'NotEmpty')) {
$exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'firstname']));
}
if (!\Zend_Validate::is($customerAddressModel->getLastname(), 'NotEmpty')) {
$exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'lastname']));
}
if (!\Zend_Validate::is($customerAddressModel->getStreetLine(1), 'NotEmpty')) {
$exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'street']));
}
if (!\Zend_Validate::is($customerAddressModel->getCity(), 'NotEmpty')) {
$exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'city']));
}
if (!\Zend_Validate::is($customerAddressModel->getTelephone(), 'NotEmpty')) {
$exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'telephone']));
}
$havingOptionalZip = $this->directoryData->getCountriesWithOptionalZip();
if (!in_array($customerAddressModel->getCountryId(), $havingOptionalZip) && !\Zend_Validate::is($customerAddressModel->getPostcode(), 'NotEmpty')) {
$exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'postcode']));
}
if (!\Zend_Validate::is($customerAddressModel->getCountryId(), 'NotEmpty')) {
$exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'countryId']));
}
if ($customerAddressModel->getCountryModel()->getRegionCollection()->getSize() && !\Zend_Validate::is($customerAddressModel->getRegionId(), 'NotEmpty') && $this->directoryData->isRegionRequired($customerAddressModel->getCountryId())) {
$exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'regionId']));
}
return $exception;
}
示例4: testGetCountriesWithOptionalZip
/**
* @param string $configValue
* @param mixed $expected
* @dataProvider countriesCommaListDataProvider
*/
public function testGetCountriesWithOptionalZip($configValue, $expected)
{
$this->_config->expects($this->once())->method('getValue')->with('general/country/optional_zip_countries')->will($this->returnValue($configValue));
$result = $this->_object->getCountriesWithOptionalZip();
$this->assertEquals($expected, $result);
}
示例5: getOptionalZipCountries
/**
* Return ISO2 country codes, which have optional Zip/Postal pre-configured
*
* @return array|string
*/
public function getOptionalZipCountries()
{
return $this->_directoryHelper->getCountriesWithOptionalZip();
}
示例6: isZipRequired
/**
* Checks if zip for current country id is required
*
* @param string $countryId
* @return bool
*/
protected function isZipRequired($countryId)
{
return !in_array($countryId, $this->directoryHelper->getCountriesWithOptionalZip());
}