|
|
|
@ -4,8 +4,9 @@ namespace Drupal\islandora\ContextProvider;
|
|
|
|
|
|
|
|
|
|
use Drupal\Core\Cache\CacheableMetadata; |
|
|
|
|
use Drupal\Core\Plugin\Context\Context; |
|
|
|
|
use Drupal\Core\Plugin\Context\ContextDefinition; |
|
|
|
|
use Drupal\Core\Plugin\Context\ContextProviderInterface; |
|
|
|
|
use Drupal\Core\Plugin\Context\EntityContext; |
|
|
|
|
use Drupal\Core\Plugin\Context\EntityContextDefinition; |
|
|
|
|
use Drupal\Core\Routing\RouteMatchInterface; |
|
|
|
|
use Drupal\Core\StringTranslation\StringTranslationTrait; |
|
|
|
|
|
|
|
|
@ -24,7 +25,7 @@ class TermRouteContextProvider implements ContextProviderInterface {
|
|
|
|
|
protected $routeMatch; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Constructs a new FileRouteContextProvider. |
|
|
|
|
* Constructs a new TermRouteContextProvider. |
|
|
|
|
* |
|
|
|
|
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match |
|
|
|
|
* The route match object. |
|
|
|
@ -37,10 +38,10 @@ class TermRouteContextProvider implements ContextProviderInterface {
|
|
|
|
|
* {@inheritdoc} |
|
|
|
|
*/ |
|
|
|
|
public function getRuntimeContexts(array $unqualified_context_ids) { |
|
|
|
|
$context_definition = new ContextDefinition('entity:taxonomy_term', NULL, FALSE); |
|
|
|
|
$context_definition = EntityContextDefinition::fromEntityTypeId('entity:taxonomy_term')->setLabel(NULL)->setRequired(FALSE); |
|
|
|
|
$value = NULL; |
|
|
|
|
|
|
|
|
|
// Hack the file out of the route. |
|
|
|
|
// Hack the taxonomy term out of the route. |
|
|
|
|
$route_object = $this->routeMatch->getRouteObject(); |
|
|
|
|
if ($route_object) { |
|
|
|
|
$route_contexts = $route_object->getOption('parameters'); |
|
|
|
@ -64,7 +65,7 @@ class TermRouteContextProvider implements ContextProviderInterface {
|
|
|
|
|
* {@inheritdoc} |
|
|
|
|
*/ |
|
|
|
|
public function getAvailableContexts() { |
|
|
|
|
$context = new Context(new ContextDefinition('entity:taxonomy_term', $this->t('Term from URL'))); |
|
|
|
|
$context = EntityContext::fromEntityTypeId('entity:taxonomy_term', $this->t('Term from URL')); |
|
|
|
|
return ['taxonomy_term' => $context]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|