protected function renderLink($field, $makeLinks, $textOnly, $encode) { $fieldName = $field->fieldName; $linkedModel = $this->owner->getLinkedModel($fieldName, false); if ($linkedModel === null) { return $this->render($this->owner->{$fieldName}, $encode); } else { return $makeLinks ? $linkedModel->getLink() : $linkedModel->name; } }