4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC. All rights reserved. |
7 | This work is published under the GNU AGPLv3 license with some |
8 | permitted exceptions and without any warranty. For full license |
9 | and copyright information, see https://civicrm.org/licensing |
10 +--------------------------------------------------------------------+
16 * @copyright CiviCRM LLC https://civicrm.org/licensing
22 namespace Civi\Api4\Action\Address
;
26 * @method bool getStreetParsing()
27 * @method $this setStreetParsing(bool $streetParsing)
28 * @method bool getSkipGeocode()
29 * @method $this setSkipGeocode(bool $skipGeocode)
30 * @method bool getFixAddress()
31 * @method $this setFixAddress(bool $fixAddress)
33 trait AddressSaveTrait
{
36 * Optional param to indicate you want the street_address field parsed into individual params
40 protected $streetParsing = FALSE;
43 * Optional param to indicate you want to skip geocoding (useful when importing a lot of addresses at once, the job Geocode and Parse Addresses can execute this task after the import)
47 protected $skipGeocode = FALSE;
50 * When true, apply various fixes to the address before insert.
54 protected $fixAddress = TRUE;
59 protected function writeObjects($items) {
60 foreach ($items as &$item) {
61 if ($this->streetParsing
&& !empty($item['street_address'])) {
62 $item = array_merge($item, \CRM_Core_BAO_Address
::parseStreetAddress($item['street_address']));
64 $item['skip_geocode'] = $this->skipGeocode
;
66 return parent
::writeObjects($items);