handle beforeMarshal little better
Some checks failed
CI / testsuite (mysql, 8.2, ) (push) Failing after 4m14s
CI / testsuite (mysql, 8.4, ) (push) Has started running
CI / testsuite (pgsql, 8.2, ) (push) Has started running
CI / testsuite (pgsql, 8.4, ) (push) Has started running
CI / testsuite (sqlite, 8.2, ) (push) Has been cancelled
CI / testsuite (sqlite, 8.2, prefer-lowest) (push) Has been cancelled
CI / testsuite (sqlite, 8.4, ) (push) Has been cancelled
CI / Coding Standard & Static Analysis (push) Has been cancelled

This commit is contained in:
2026-02-11 19:25:28 -08:00
parent af0a980e37
commit b3b410b4c3

View File

@@ -175,11 +175,11 @@ class AddressesTable extends Table {
* @return void * @return void
*/ */
public function beforeMarshal(EventInterface $event, ArrayObject $data, ArrayObject $options): void { public function beforeMarshal(EventInterface $event, ArrayObject $data, ArrayObject $options): void {
if ($data['state_id'] && !isset($data['state'])) { if (($data['state_id'] ?? false) && !isset($data['state'])) {
$state = $this->States->find()->where(['id' => $data['state_id']])->first(); $state = $this->States->find()->where(['id' => $data['state_id']])->first();
$data['state'] = $state->name ?? null; $data['state'] = $state->name ?? null;
} }
if ($data['country_id'] && !isset($data['country'])) { if (($data['country_id'] ?? false) && !isset($data['country'])) {
$country = $this->Countries->find()->where(['id' => $data['country_id']])->first(); $country = $this->Countries->find()->where(['id' => $data['country_id']])->first();
$data['country'] = $country->name ?? null; $data['country'] = $country->name ?? null;
} }