diff --git a/core/modules/taxonomy/src/TermListBuilder.php b/core/modules/taxonomy/src/TermListBuilder.php index c8ddc2d..52ac3b5 100644 --- a/core/modules/taxonomy/src/TermListBuilder.php +++ b/core/modules/taxonomy/src/TermListBuilder.php @@ -7,7 +7,12 @@ namespace Drupal\taxonomy; +use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityListBuilder; +use Drupal\Core\Entity\EntityStorageInterface; +use Drupal\Core\Entity\EntityTypeInterface; +use Drupal\Core\Routing\RedirectDestinationInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Provides a taxonomy term list builder. @@ -15,6 +20,53 @@ class TermListBuilder extends EntityListBuilder { /** + * The redirect destination. + * + * @var \Drupal\Core\Routing\RedirectDestinationInterface + */ + protected $redirectDestination; + + /** + * {@inheritdoc} + */ + public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { + return new static( + $container->get('redirect.destination'), + $entity_type, + $container->get('entity.manager')->getStorage($entity_type->id()) + ); + } + + /** + * Constructs a new instance. + * + * @param \Drupal\Core\Routing\RedirectDestinationInterface + * The redirect destination. + * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type + * The entity type definition. + * @param \Drupal\Core\Entity\EntityStorageInterface $storage + * The entity storage class. + */ + public function __construct(RedirectDestinationInterface $redirect_destination, EntityTypeInterface $entity_type, EntityStorageInterface $storage) { + $this->entityTypeId = $entity_type->id(); + $this->storage = $storage; + $this->entityType = $entity_type; + $this->redirectDestination = $redirect_destination; + } + + /** + * {@inheritdoc} + */ + public function getOperations(EntityInterface $entity) { + $operations = parent::getOperations($entity); + foreach ($operations as &$operation) { + $operation['query']['destination'] = $this->redirectDestination->get(); + } + + return $operations; + } + + /** * {@inheritdoc} */ public function render() {