public function TaxonomyViewsIntegratorManager::getTaxonomyTermView in Taxonomy Views Integrator 8
Return the taxonomy term View per taxonomy view integrator settings.
Parameters
\Drupal\taxonomy\TermInterface $taxonomy_term: The term to render the view for.
Return value
array Views results render array.
Overrides TaxonomyViewsIntegratorManagerInterface::getTaxonomyTermView
File
- src/
Service/ TaxonomyViewsIntegratorManager.php, line 129
Class
- TaxonomyViewsIntegratorManager
- Default implementation of TaxonomyViewsIntegratorManagerInterface.
Namespace
Drupal\tvi\ServiceCode
public function getTaxonomyTermView(TermInterface $taxonomy_term) {
$view_info = $this
->getTaxonomyTermViewAndDisplayId($taxonomy_term);
$config = $this
->getTermConfigSettings($taxonomy_term);
$view_arguments = [
$taxonomy_term
->id(),
];
// If the option to pass all args to views is enabled, pass them on.
if ($config
->get('pass_arguments')) {
$view_arguments += $this
->getRequestUriArguments();
}
$build = NULL;
if ($view_info['display_id']) {
$view = Views::getView($view_info['view_id']);
// Ensure view exists and is enabled.
if ($view && $view->storage
->status()) {
$view->override_url = Url::fromUri($this->requestStack
->getCurrentRequest()
->getUri());
$build = $view
->executeDisplay($view_info['display_id'], $view_arguments);
}
}
if (!$build) {
$build = $this->entityTypeManager
->getViewBuilder('taxonomy_term')
->view($taxonomy_term, 'full');
}
return $build;
}