Skip to content

Commit

Permalink
Merge pull request #60 from australiangreens/fix/update-tasks-to-api4
Browse files Browse the repository at this point in the history
Switch createentity calls to Api4
  • Loading branch information
johntwyman authored Dec 12, 2023
2 parents 5f85bfd + f299db7 commit 39d61a6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog
All notable changes for the CiviGeometry extension will be noted here.

## [1.13.0] - 2023-12-12
### Changed
- geoplaceAddress task refactored to use APIv4 calls instead of APIv3

## [1.12.0] - 2023-08-01
### Added
- Geometry.getcachedoverlaps APIv4 method
Expand Down
18 changes: 10 additions & 8 deletions CRM/CiviGeometry/Tasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ public static function geoplaceAddress(CRM_Queue_TaskContext $ctx, $address_id)
])['values'];
if (!empty($geometry_ids)) {
foreach ($geometry_ids as $geometry_id) {
civicrm_api3('Address', 'creategeometries', [
'address_id' => $address['id'],
'geometry_id' => $geometry_id,
]);
\Civi\Api4\Geometry::createEntity(FALSE)
->setEntity_id($address['id'])
->setEntity_table('civicrm_address')
->setGeometry_id($geometry_id)
->execute();
}
}
$addressObject = new CRM_Core_BAO_Address();
Expand All @@ -49,10 +50,11 @@ public static function geoplaceAddress(CRM_Queue_TaskContext $ctx, $address_id)
*/
public static function buildGeometryRelationships(CRM_Queue_TaskContext $ctx, $geometry_id) {
foreach (CRM_CiviGeometry_BAO_Geometry::getAddresses($geometry_id) as $match) {
civicrm_api3('Address', 'creategeometries', [
'geometry_id' => $match['geometry_id'],
'address_id' => $match['address_id'],
]);
\Civi\Api4\Geometry::createEntity(FALSE)
->setEntity_id($match['address_id'])
->setEntity_table('civicrm_address')
->setGeometry_id($match['geometry_id'])
->execute();
}
return TRUE;
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}
],
"require": {
"composer/installers": "^1.6"
"composer/installers": "^1.6 || ^2.2"
},
"config": {
"allow-plugins": {
Expand Down
4 changes: 2 additions & 2 deletions info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<url desc="Support">https://github.com/australiangreens/au.org.greens.civigeometry</url>
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2023-08-01</releaseDate>
<version>1.12.0</version>
<releaseDate>2023-12-12</releaseDate>
<version>1.13.0</version>
<develStage>stable</develStage>
<compatibility>
<ver>5.45</ver>
Expand Down

0 comments on commit 39d61a6

Please sign in to comment.