How to override entity:link() function? I have an entity with entitylisthandler.

In entitylisthandler, i have a function to build row like:

public function buildRow(EntityInterface $entity) {

    /* @var $entity \Drupal\mymodule\Entity\xyz*/
    $row['id'] = $entity-&gt;id();
    $row['config_name'] = $entity-&gt;link();
    //$row['first_name'] = $entity-&gt;first_name-&gt;value;
    $row['ctype'] = $entity-&gt;ctype-&gt;value;
    return $row + parent::buildRow($entity);
  }


In @line 3:

$row['config_name'] = $entity-&gt;link();


I'm calling link function here which calls entity canonical link.

How to change this default value 'canonical' to some other link like 'delete-form'?

This is the Drupal core link function which I'm trying to override in entitylistbuilder file.

public function link($text = NULL, $rel = 'delete-form', array $options = []) {
  return $this-&gt;toLink($text, $rel, $options)-&gt;toString();
  }


I have changed its argument from 'canonical' to 'delete-form', but it won't work.
You should not change the core function. What core does, if $rel is not set, it uses 'canonical'. If you want to use 'delete-form' instead, put this as an argument when using the link function:

$row['config_name'] = $entity-&gt;link(NULL, 'delete-form');


BTW, link() is deprecated, so use toLink() instead.