/** * Writes the custom parent fields * * @param string[] $fields * @param ApiInterface $entity * * @return void */ private function writeCustomParents($fields, ApiInterface $entity) { foreach ($entity->getCustomParentRelationships() as $customRelationship) { $name = $customRelationship->getReferencedFields(); if (array_key_exists($name, $fields)) { $entity->writeAttribute($name, $fields[$name]); } } }