Skip to content

Commit

Permalink
Additional fixes to Pipelines (CFM-33)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benn Oshrin committed Jan 20, 2024
1 parent 5559c0b commit 2266c34
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/src/Lib/Traits/EntityMetaTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public function isProbablyThisArray(array $data): bool {

foreach($data as $field => $value) {
if((!isset($this->$field) && !empty($value)) // Value in $data but not $entity
|| (isset($this->$field) && empty($value)) // Value in $entity but not $data
|| (isset($this->$field) && empty($value) // Value in $entity but not $data
&& !empty($this->$field)) // ... and $entity is not falsey
|| (isset($this->$field) && $this->$field != $value)) { // Values don't match
// Not a match
$match = false;
Expand Down
18 changes: 16 additions & 2 deletions app/src/Model/Table/PipelinesTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,14 @@ protected function duplicateFilterEntityData($entity): array {
$newdata['status']
);

// Timestamps are FrozenTime objects in the entity data, and is_scalar
// will filter them out, so convert them to strings
foreach(['valid_from', 'valid_through'] as $attr) {
if(!empty($entity->$attr)) {
$newdata[$attr] = $entity->$attr->i18nFormat('yyyy-MM-dd HH:mm:ss');
}
}

// This will remove anything that isn't stringy
return array_filter($newdata, 'is_scalar');
}
Expand Down Expand Up @@ -1269,14 +1277,20 @@ protected function syncExternalIdentity(
// $arecord should include the associated models, so we don't need
// to do any special handling for them.

$associated = [];

if($model == 'ExternalIdentityRoles') {
$associated = ['Addresses', 'AdHocAttributes', 'TelephoneNumbers'];
}

$newentity = $this->Cos->People->ExternalIdentities->$model->newEntity(
$arecord,
['associated' => ['Addresses', 'AdHocAttributes', 'TelephoneNumbers']]
['associated' => $associated]
);

$this->Cos->People->ExternalIdentities->$model->saveOrFail(
$newentity,
['associated' => ['Addresses', 'AdHocAttributes', 'TelephoneNumbers']]
['associated' => $associated]
);

$this->llog('trace', "Added $model " . $newentity->id . " for External Identity " . $externalIdentityEntity->id);
Expand Down

0 comments on commit 2266c34

Please sign in to comment.