class ContactLink extends LinkBase
{ /**
* {@inheritdoc}
*/
public function buildOptionsForm(&
$form, FormStateInterface
$form_state) { parent::
buildOptionsForm($form,
$form_state);
$form['text'
]['#title'
] =
$this->
t('Link label'
);
$form['text'
]['#required'
] = TRUE;
$form['text'
]['#default_value'
] =
empty($this->options
['text'
]) ?
$this->
getDefaultLabel() :
$this->options
['text'
];
} /**
* {@inheritdoc}
*/
protected function getUrlInfo(ResultRow
$row) { $entity =
$this->
getEntity($row);
if (!
$entity) { return NULL;
} return Url::
fromRoute('entity.user.contact_form',
['user' =>
$entity->
id()]);
}