+ $this->fillPrimary($params['address'][$values['location_type_id']], $values, 'address', CRM_Utils_Array::value('id', $params));
+ return TRUE;
+ }
+
+ /**
+ * Get the field metadata for the relevant entity.
+ *
+ * @param string $entity
+ *
+ * @return array
+ */
+ protected function getMetadataForEntity($entity) {
+ if (!isset($this->fieldMetadata[$entity])) {
+ $className = "CRM_Core_DAO_$entity";
+ $this->fieldMetadata[$entity] = $className::fields();
+ }
+ return $this->fieldMetadata[$entity];
+ }
+
+ /**
+ * Fill in the primary location.
+ *
+ * If the contact has a primary address we update it. Otherwise
+ * we add an address of the default location type.
+ *
+ * @param array $params
+ * Address block parameters
+ * @param array $values
+ * Input values
+ * @param string $entity
+ * - address, email, phone
+ * @param int|null $contactID
+ *
+ * @throws \CiviCRM_API3_Exception
+ */
+ protected function fillPrimary(&$params, $values, $entity, $contactID) {