Skip to content
Snippets Groups Projects
Commit 7169bf98 authored by simon's avatar simon
Browse files

fix: less chatty hook_update

parent bc50f473
Branches
Tags v1.0.0
No related merge requests found
......@@ -6,14 +6,15 @@ use Drupal\accounting\Entity\AccountingAccount;
* Invert account - ogm relation for deposito accounts.
*/
function banking_ogm_update_8001(&$sandbox) {
$inverted = 0;
foreach (AccountingAccount::loadMultiple() as $a) {
if ($a->hasField('field_ogm') && $a->get('field_ogm')->entity) {
$ogm = $a->get('field_ogm')->entity;
if ($ogm->hasField('account') && $ogm->get('account')->target_id != $a->id()) {
error_log("Setting account for ogm {$ogm->getName()}");
$ogm->set('account', $a->id());
$ogm->save();
}
}
}
return "Updated account for {$inverted} OGM's.";
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment