-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HPC-9281: Adds an 'Add team' link to the team list page and fixes the…
… breadcrumbs
- Loading branch information
Showing
6 changed files
with
133 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
ghi_teams.add_team: | ||
route_name: entity.taxonomy_term.add_form | ||
route_parameters: | ||
taxonomy_vocabulary: team | ||
title: Add team | ||
appears_on: | ||
- view.teams.page_teams |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
html/modules/custom/ghi_teams/src/Controller/TaxonomyTermController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
namespace Drupal\ghi_teams\Controller; | ||
|
||
use Drupal\Core\Controller\ControllerBase; | ||
use Drupal\Core\Routing\RouteMatchInterface; | ||
use Symfony\Component\DependencyInjection\ContainerInterface; | ||
|
||
/** | ||
* Controller class for taxonomy terms. | ||
* | ||
* The main thing this does, is to change the page titles for the different | ||
* taxonomy pages (add, edit, delete, ...). | ||
* | ||
* @see \Drupal\ghi_teams\EventSubscriber\TaxonomyTermRouteSubscriber | ||
*/ | ||
class TaxonomyTermController extends ControllerBase { | ||
|
||
/** | ||
* The route match. | ||
* | ||
* @var \Drupal\Core\Routing\RouteMatchInterface | ||
*/ | ||
protected $routeMatch; | ||
|
||
/** | ||
* Public constructor. | ||
* | ||
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match | ||
* The route match. | ||
*/ | ||
public function __construct(RouteMatchInterface $route_match) { | ||
$this->routeMatch = $route_match; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function create(ContainerInterface $container) { | ||
$instance = new static($container->get('current_route_match')); | ||
return $instance; | ||
} | ||
|
||
/** | ||
* Title callback for the term add page. | ||
* | ||
* @return \Drupal\Core\StringTranslation\TranslatableMarkup | ||
* The title. | ||
*/ | ||
public function addTitle() { | ||
/** @var \Drupal\taxonomy\VocabularyInterface $term */ | ||
$vocabulary = $this->routeMatch->getParameter('taxonomy_vocabulary'); | ||
return $vocabulary ? $this->t('Add @label', [ | ||
'@label' => strtolower($vocabulary->label()), | ||
]) : $this->t('Add term'); | ||
} | ||
|
||
/** | ||
* Title callback for the term edit page. | ||
* | ||
* @return \Drupal\Core\StringTranslation\TranslatableMarkup | ||
* The title. | ||
*/ | ||
public function editTitle() { | ||
/** @var \Drupal\taxonomy\TermInterface $term */ | ||
$term = $this->routeMatch->getParameter('taxonomy_term'); | ||
return $term ? $this->t('Edit @label', [ | ||
'@label' => strtolower($term->vid->entity->label()), | ||
]) : $this->t('Edit term'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters