Skip to content

Commit

Permalink
HSD8-1416 Fix entity usage link
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish committed Oct 2, 2023
1 parent f72d8f3 commit 5fabe41
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/Plugin/views/field/EntityUsageLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ public function query() {
$this->ensureMyTable();
// Add the field.
$params = $this->options['group_type'] != 'group' ? ['function' => $this->options['group_type']] : [];

dpm($params);
$this->field_alias = $this->query->addField($this->tableAlias, 'source_type', NULL, $params);
$this->field_alias_id = $this->query->addField($this->tableAlias, 'source_id', NULL, $params);
$this->field_alias_vid = $this->query->addField($this->tableAlias, 'source_vid', NULL, $params);
$this->addAdditionalFields();
}

Expand All @@ -63,11 +64,20 @@ public function query() {
public function render(ResultRow $values) {
$type = $values->{$this->field_alias};
$id = $values->{$this->field_alias_id};
$vid = $values->{$this->field_alias_vid};
if (!$type || !$id) {
return '';
return null;
}
if ($vid) {
/** @var \Drupal\Core\Entity\RevisionLogInterface $child */
$child = $this->entityTypeManager->getStorage($type)->loadRevision($vid);
if (!$child->isLatestRevision()) {
return NULL;
}
}
else {
$child = $this->entityTypeManager->getStorage($type)->load($id);
}

$child = $this->entityTypeManager->getStorage($type)->load($id);
$parent = $this->getParent($child);
if ($parent->hasLinkTemplate('canonical')) {
return $parent->toLink()->toRenderable();
Expand Down

0 comments on commit 5fabe41

Please sign in to comment.