Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/comment/src/CommentBreadcrumbBuilder.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | c75dbcec494b |
children |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
2 | 2 |
3 namespace Drupal\comment; | 3 namespace Drupal\comment; |
4 | 4 |
5 use Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface; | 5 use Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface; |
6 use Drupal\Core\Breadcrumb\Breadcrumb; | 6 use Drupal\Core\Breadcrumb\Breadcrumb; |
7 use Drupal\Core\Entity\EntityManagerInterface; | 7 use Drupal\Core\Entity\EntityTypeManagerInterface; |
8 use Drupal\Core\Link; | 8 use Drupal\Core\Link; |
9 use Drupal\Core\Routing\RouteMatchInterface; | 9 use Drupal\Core\Routing\RouteMatchInterface; |
10 use Drupal\Core\StringTranslation\StringTranslationTrait; | 10 use Drupal\Core\StringTranslation\StringTranslationTrait; |
11 | 11 |
12 /** | 12 /** |
23 protected $storage; | 23 protected $storage; |
24 | 24 |
25 /** | 25 /** |
26 * Constructs the CommentBreadcrumbBuilder. | 26 * Constructs the CommentBreadcrumbBuilder. |
27 * | 27 * |
28 * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager | 28 * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager |
29 * The entity manager. | 29 * The entity type manager. |
30 */ | 30 */ |
31 public function __construct(EntityManagerInterface $entity_manager) { | 31 public function __construct(EntityTypeManagerInterface $entity_type_manager) { |
32 $this->storage = $entity_manager->getStorage('comment'); | 32 $this->storage = $entity_type_manager->getStorage('comment'); |
33 } | 33 } |
34 | 34 |
35 /** | 35 /** |
36 * {@inheritdoc} | 36 * {@inheritdoc} |
37 */ | 37 */ |
46 $breadcrumb = new Breadcrumb(); | 46 $breadcrumb = new Breadcrumb(); |
47 $breadcrumb->addCacheContexts(['route']); | 47 $breadcrumb->addCacheContexts(['route']); |
48 $breadcrumb->addLink(Link::createFromRoute($this->t('Home'), '<front>')); | 48 $breadcrumb->addLink(Link::createFromRoute($this->t('Home'), '<front>')); |
49 | 49 |
50 $entity = $route_match->getParameter('entity'); | 50 $entity = $route_match->getParameter('entity'); |
51 $breadcrumb->addLink(new Link($entity->label(), $entity->urlInfo())); | 51 $breadcrumb->addLink(new Link($entity->label(), $entity->toUrl())); |
52 $breadcrumb->addCacheableDependency($entity); | 52 $breadcrumb->addCacheableDependency($entity); |
53 | 53 |
54 if (($pid = $route_match->getParameter('pid')) && ($comment = $this->storage->load($pid))) { | 54 if (($pid = $route_match->getParameter('pid')) && ($comment = $this->storage->load($pid))) { |
55 /** @var \Drupal\comment\CommentInterface $comment */ | 55 /** @var \Drupal\comment\CommentInterface $comment */ |
56 $breadcrumb->addCacheableDependency($comment); | 56 $breadcrumb->addCacheableDependency($comment); |
57 // Display link to parent comment. | 57 // Display link to parent comment. |
58 // @todo Clean-up permalink in https://www.drupal.org/node/2198041 | 58 // @todo Clean-up permalink in https://www.drupal.org/node/2198041 |
59 $breadcrumb->addLink(new Link($comment->getSubject(), $comment->urlInfo())); | 59 $breadcrumb->addLink(new Link($comment->getSubject(), $comment->toUrl())); |
60 } | 60 } |
61 | 61 |
62 return $breadcrumb; | 62 return $breadcrumb; |
63 } | 63 } |
64 | 64 |