当前位置: 首页>>代码示例>>PHP>>正文


PHP Data::getCountriesWithOptionalZip方法代码示例

本文整理汇总了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;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:13,代码来源:Postcode.php

示例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;
 }
开发者ID:opexsw,项目名称:magento2,代码行数:40,代码来源:AbstractAddress.php

示例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;
 }
开发者ID:nja78,项目名称:magento2,代码行数:42,代码来源:AddressRepository.php

示例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);
 }
开发者ID:buskamuza,项目名称:magento2-skeleton,代码行数:11,代码来源:DataTest.php

示例5: getOptionalZipCountries

 /**
  * Return ISO2 country codes, which have optional Zip/Postal pre-configured
  *
  * @return array|string
  */
 public function getOptionalZipCountries()
 {
     return $this->_directoryHelper->getCountriesWithOptionalZip();
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:9,代码来源:Addresses.php

示例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());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:10,代码来源:Validator.php


注:本文中的Magento\Directory\Helper\Data::getCountriesWithOptionalZip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。