26 public static function convertLinksToOrm(
Address $address): EO_AddressLink_Collection
28 $result =
new EO_AddressLink_Collection();
31 foreach ($address->
getLinks() as $link)
34 (
new EO_AddressLink())
35 ->setAddressId($address->
getId())
36 ->setEntityId($link->getAddressLinkEntityId())
37 ->setEntityType($link->getAddressLinkEntityType())
50 public static function convertFieldsToOrm(
Address $address): EO_AddressField_Collection
52 $result =
new EO_AddressField_Collection();
53 $normalizer = Address\Normalizer\Builder::build($address->
getLanguageId());
58 $value = $field->getValue();
60 (
new EO_AddressField())
61 ->setType($field->getType())
62 ->setValue($field->getValue())
63 ->setAddressId($address->
getId())
64 ->setValueNormalized( $normalizer->normalize($value))
79 public static function convertFromOrm(EO_Address $ormAddress):
Address
81 $result =
new Address($ormAddress->getLanguageId());
82 $result->setId($ormAddress->getId())
83 ->setLatitude($ormAddress->getLatitude())
84 ->setLongitude($ormAddress->getLongitude());
87 foreach ($ormAddress->getFields() as $field)
89 $result->setFieldValue($field->getType(), $field->getValue());
92 if($ormLocation = $ormAddress->getLocation())
94 $location = \Bitrix\Location\Entity\Location\Converter\OrmConverter::createLocation(
96 $ormAddress->getLanguageId()
101 $result->setLocation($location);
105 if($links = $ormAddress->getLinks())
108 foreach ($links as $link)
110 $result->addLink($link->getEntityId(), $link->getEntityType());
131 foreach ($collection as $item)
133 $result->addItem(self::convertFromOrm($item));