Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
[SDPA-4450] turns off truncated alias in the list (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-gao authored Aug 13, 2020
1 parent 96ba75f commit 1c6ec7b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/TideSitePathAliasListBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Drupal\tide_site;

use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Url;
use Drupal\path\PathAliasListBuilder;

/**
* TideSitePathAliasListBuilder.
*
* We don't want the alias link to be truncated in the listing page.
*/
class TideSitePathAliasListBuilder extends PathAliasListBuilder {

/**
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity) {
$parent = parent::buildRow($entity);
$alias = $entity->getAlias();
$path = $entity->getPath();
$url = Url::fromUserInput($path);
$parent['data']['alias']['data'] = [
'#type' => 'link',
'#title' => $alias,
'#url' => $url->setOption('attributes', ['title' => $alias]),
];
return $parent;
}

}
10 changes: 10 additions & 0 deletions tide_site.module
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use Drupal\tide_site\TideSiteMenuAutocreate;
use Drupal\views\ViewExecutable;
use Drupal\path_alias\Entity\PathAlias;
use Drupal\path_alias\PathAliasInterface;
use Drupal\tide_site\TideSitePathAliasListBuilder;

/**
* Implements hook_entity_bundle_create().
Expand Down Expand Up @@ -681,3 +682,12 @@ function tide_site_form_views_exposed_form_alter(&$form, FormStateInterface $for
}
}
}

/**
* Implements hook_entity_type_alter().
*/
function tide_site_entity_type_alter(array &$entity_types) {
if (isset($entity_types['path_alias'])) {
$entity_types['path_alias']->setListBuilderClass(TideSitePathAliasListBuilder::class);
}
}

0 comments on commit 1c6ec7b

Please sign in to comment.