2cd402cd0070a687cb6c6550f914402d9c107d8a
[yaffs-website] / web / core / modules / views / src / Plugin / views / field / EntityLink.php
1 <?php
2
3 namespace Drupal\views\Plugin\views\field;
4
5 use Drupal\views\ResultRow;
6
7 /**
8  * Field handler to present a link to an entity.
9  *
10  * @ingroup views_field_handlers
11  *
12  * @ViewsField("entity_link")
13  */
14 class EntityLink extends LinkBase {
15
16   /**
17    * {@inheritdoc}
18    */
19   public function render(ResultRow $row) {
20     return $this->getEntity($row) ? parent::render($row) : [];
21   }
22
23   /**
24    * {@inheritdoc}
25    */
26   protected function getUrlInfo(ResultRow $row) {
27     $template = $this->getEntityLinkTemplate();
28     return $this->getEntity($row)->urlInfo($template);
29   }
30
31   /**
32    * Returns the entity link template name identifying the link route.
33    *
34    * @returns string
35    *   The link template name.
36    */
37   protected function getEntityLinkTemplate() {
38     return 'canonical';
39   }
40
41   /**
42    * {@inheritdoc}
43    */
44   protected function getDefaultLabel() {
45     return $this->t('view');
46   }
47
48 }