public function TaxonomyViewsIntegratorManager::getTaxonomyTermViewAndDisplayId in Taxonomy Views Integrator 8
Return array with view and display id for current term based on settings.
Parameters
\Drupal\taxonomy\TermInterface $taxonomy_term: An object with term entity.
Return value
array An array with view_id and display_id for current term.
Overrides TaxonomyViewsIntegratorManagerInterface::getTaxonomyTermViewAndDisplayId
1 call to TaxonomyViewsIntegratorManager::getTaxonomyTermViewAndDisplayId()
- TaxonomyViewsIntegratorManager::getTaxonomyTermView in src/
Service/ TaxonomyViewsIntegratorManager.php - Return the taxonomy term View per taxonomy view integrator settings.
File
- src/
Service/ TaxonomyViewsIntegratorManager.php, line 162
Class
- TaxonomyViewsIntegratorManager
- Default implementation of TaxonomyViewsIntegratorManagerInterface.
Namespace
Drupal\tvi\ServiceCode
public function getTaxonomyTermViewAndDisplayId(TermInterface $taxonomy_term) {
// If we have no matches, we are going to call the default core term view.
$view_name = 'taxonomy_term';
$view_id = 'page_1';
$global_config = $this
->getDefaultConfigSettings();
if ($global_config
->get('disable_default_view')) {
$view_name = NULL;
$view_id = NULL;
}
elseif ($global_config
->get('enable_override')) {
$view_name = $global_config
->get('view');
$view_id = $global_config
->get('view_display');
}
// Check for global overrides.
$term_config = $this
->getTermConfigSettings($taxonomy_term);
if ($term_config
->get('enable_override')) {
$view_name = $term_config
->get('view');
$view_id = $term_config
->get('view_display');
}
else {
// Check parent terms and vocab for settings.
$vocab_config = $this
->getVocabularyConfigSettings($taxonomy_term);
if ($vocab_config
->get('enable_override') && $vocab_config
->get('inherit_settings')) {
$view_name = $vocab_config
->get('view');
$view_id = $vocab_config
->get('view_display');
}
$parents = $this
->getTermParents($taxonomy_term);
unset($parents[$taxonomy_term
->id()]);
foreach ($parents as $parent) {
$parent_config = $this
->getTermConfigSettings($parent);
if ($parent_config
->get('enable_override') && $parent_config
->get('inherit_settings')) {
$view_name = $parent_config
->get('view');
$view_id = $parent_config
->get('view_display');
break;
}
}
}
return [
'view_id' => $view_name,
'display_id' => $view_id,
];
}