Skip to content

Commit

Permalink
Move Magento\Sales\Model\Order\Address\Validator logic from construct…
Browse files Browse the repository at this point in the history
… to validate method
  • Loading branch information
Bartlomiejsz committed Mar 12, 2019
1 parent a089cfe commit 068eedf
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions app/code/Magento/Sales/Model/Order/Address/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ public function __construct(
$this->countryFactory = $countryFactory;
$this->eavConfig = $eavConfig ?: ObjectManager::getInstance()
->get(EavConfig::class);
}

/**
*
* @param \Magento\Sales\Model\Order\Address $address
* @return array
*/
public function validate(Address $address)
{
$warnings = [];

if ($this->isTelephoneRequired()) {
$this->required['telephone'] = 'Phone Number';
Expand All @@ -72,16 +82,7 @@ public function __construct(
if ($this->isFaxRequired()) {
$this->required['fax'] = 'Fax';
}
}

/**
*
* @param \Magento\Sales\Model\Order\Address $address
* @return array
*/
public function validate(Address $address)
{
$warnings = [];
foreach ($this->required as $code => $label) {
if (!$address->hasData($code)) {
$warnings[] = sprintf('%s is a required field', $label);
Expand Down

0 comments on commit 068eedf

Please sign in to comment.