Skip to content
Snippets Groups Projects

Issue #3469457: Cannot output domain source in content view - buildUrl() on null

Merged Issue #3469457: Cannot output domain source in content view - buildUrl() on null
1 unresolved thread
Merged Rob Sembrat requested to merge issue/domain-3469457:3469457-cannot-output-domain into 2.0.x
1 unresolved thread
1 file
+ 8
6
Compare changes
  • Side-by-side
  • Inline
@@ -23,10 +23,12 @@ class DomainSource extends EntityField {
@@ -23,10 +23,12 @@ class DomainSource extends EntityField {
foreach ($items as &$item) {
foreach ($items as &$item) {
$object = $item['raw'];
$object = $item['raw'];
$entity = $object->getEntity();
$entity = $object->getEntity();
$url = $entity->toUrl()->toString();
$domain = $item['rendered']['#entity'];
$domain = $item['rendered']['#options']['entity'];
$item['rendered'] = [
$item['rendered']['#type'] = 'markup';
'#type' => 'link',
$item['rendered']['#markup'] = '<a href="' . $domain->buildUrl($url) . '">' . $domain->label() . '</a>';
'#title' => $domain->label(),
 
'#url' => $entity->toUrl(),
 
];
}
}
uasort($items, [$this, 'sort']);
uasort($items, [$this, 'sort']);
}
}
@@ -38,8 +40,8 @@ class DomainSource extends EntityField {
@@ -38,8 +40,8 @@ class DomainSource extends EntityField {
* Sort the domain list, if possible.
* Sort the domain list, if possible.
*/
*/
private function sort($a, $b) {
private function sort($a, $b) {
$domainA = $a['rendered']['#options']['entity'] ?? 0;
$domainA = $a['rendered']['#entity'] ?? 0;
$domainB = $b['rendered']['#options']['entity'] ?? 0;
$domainB = $b['rendered']['#entity'] ?? 0;
if ($domainA !== 0) {
if ($domainA !== 0) {
return ($domainA->getWeight() > $domainB->getWeight()) ? 1 : 0;
return ($domainA->getWeight() > $domainB->getWeight()) ? 1 : 0;
}
}
Loading