class JobItemBreadcrumbBuilder in Translation Management Tool 8
A custom Job item breadcrumb builder.
Hierarchy
- class \Drupal\tmgmt\Menu\JobItemBreadcrumbBuilder implements BreadcrumbBuilderInterface uses StringTranslationTrait
Expanded class hierarchy of JobItemBreadcrumbBuilder
1 string reference to 'JobItemBreadcrumbBuilder'
1 service uses JobItemBreadcrumbBuilder
File
- src/
Menu/ JobItemBreadcrumbBuilder.php, line 15
Namespace
Drupal\tmgmt\MenuView source
class JobItemBreadcrumbBuilder implements BreadcrumbBuilderInterface {
use StringTranslationTrait;
/**
* {@inheritdoc}
*/
public function applies(RouteMatchInterface $route_match) {
if ($route_match
->getRouteName() == 'entity.tmgmt_job_item.canonical' && $route_match
->getParameter('tmgmt_job_item') instanceof JobItemInterface) {
return TRUE;
}
}
/**
* {@inheritdoc}
*/
public function build(RouteMatchInterface $route_match) {
$breadcrumb = new Breadcrumb();
$breadcrumb
->addLink(Link::createFromRoute($this
->t('Home'), '<front>'));
$breadcrumb
->addCacheContexts([
'route',
]);
/** @var JobItemInterface $job_item */
$job_item = $route_match
->getParameter('tmgmt_job_item');
$breadcrumb
->addCacheableDependency($job_item);
// Add links to administration, translation, job overview and job to the
// breadcrumb.
$breadcrumb
->addLink(Link::createFromRoute($this
->t('Administration'), 'system.admin'));
$breadcrumb
->addLink(Link::createFromRoute($this
->t('Translation'), 'tmgmt.admin_tmgmt'));
$breadcrumb
->addLink(Link::createFromRoute($this
->t('Job overview'), 'view.tmgmt_job_overview.page_1'));
$breadcrumb
->addLink(Link::createFromRoute($job_item
->getJob()
->label(), 'entity.tmgmt_job.canonical', array(
'tmgmt_job' => $job_item
->getJobId(),
)));
return $breadcrumb;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
JobItemBreadcrumbBuilder:: |
public | function |
Whether this breadcrumb builder should be used to build the breadcrumb. Overrides BreadcrumbBuilderInterface:: |
|
JobItemBreadcrumbBuilder:: |
public | function |
Builds the breadcrumb. Overrides BreadcrumbBuilderInterface:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |