/** * Transform contact to transient data * * @param Contact $contact * @returns array */ public static function toTransient(Contact $contact) { $supervisor = $contact->getSupervisor(); return ['id' => $contact->getId(), 'title' => $contact->getTitle(), 'name' => $contact->getName(), 'email' => $contact->getEmail(), 'supervisor' => $supervisor ? self::toTransient($supervisor) : null, 'supervised_contacts' => self::listToTransient($contact->getSupervisedContacts())]; }