Add cacheability to import index pages
This commit is contained in:
parent
0067c85215
commit
b815dacb4f
|
@ -113,10 +113,14 @@ class CsvImportController extends ControllerBase {
|
||||||
['callable' => 'menu.default_tree_manipulators:generateIndexAndSort'],
|
['callable' => 'menu.default_tree_manipulators:generateIndexAndSort'],
|
||||||
];
|
];
|
||||||
$tree = $this->menuLinkTree->transform($tree, $manipulators);
|
$tree = $this->menuLinkTree->transform($tree, $manipulators);
|
||||||
|
|
||||||
|
// Start cacheability with migrate_plus migration config entity list tag.
|
||||||
$tree_access_cacheability = new CacheableMetadata();
|
$tree_access_cacheability = new CacheableMetadata();
|
||||||
|
$tree_access_cacheability->addCacheTags($this->entityTypeManager()->getStorage('migration')->getEntityType()->getListCacheTags());
|
||||||
|
|
||||||
$links = [];
|
$links = [];
|
||||||
foreach ($tree as $element) {
|
foreach ($tree as $element) {
|
||||||
$tree_access_cacheability = $tree_access_cacheability->merge(CacheableMetadata::createFromObject($element->access));
|
$tree_access_cacheability->addCacheableDependency($element->access);
|
||||||
|
|
||||||
// Only render accessible links.
|
// Only render accessible links.
|
||||||
if (!$element->access->isAllowed()) {
|
if (!$element->access->isAllowed()) {
|
||||||
|
@ -145,6 +149,7 @@ class CsvImportController extends ControllerBase {
|
||||||
'#markup' => $this->t('You do not have any importers.'),
|
'#markup' => $this->t('You do not have any importers.'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
$tree_access_cacheability->applyTo($output);
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,10 +59,13 @@ class ImportController extends ControllerBase {
|
||||||
['callable' => 'menu.default_tree_manipulators:generateIndexAndSort'],
|
['callable' => 'menu.default_tree_manipulators:generateIndexAndSort'],
|
||||||
];
|
];
|
||||||
$tree = $this->menuLinkTree->transform($tree, $manipulators);
|
$tree = $this->menuLinkTree->transform($tree, $manipulators);
|
||||||
|
|
||||||
|
// Start cacheability for indexer list.
|
||||||
$tree_access_cacheability = new CacheableMetadata();
|
$tree_access_cacheability = new CacheableMetadata();
|
||||||
|
|
||||||
$links = [];
|
$links = [];
|
||||||
foreach ($tree as $element) {
|
foreach ($tree as $element) {
|
||||||
$tree_access_cacheability = $tree_access_cacheability->merge(CacheableMetadata::createFromObject($element->access));
|
$tree_access_cacheability->addCacheableDependency($element->access);
|
||||||
|
|
||||||
// Only render accessible links.
|
// Only render accessible links.
|
||||||
if (!$element->access->isAllowed()) {
|
if (!$element->access->isAllowed()) {
|
||||||
|
@ -91,6 +94,7 @@ class ImportController extends ControllerBase {
|
||||||
'#markup' => $this->t('You do not have any importers.'),
|
'#markup' => $this->t('You do not have any importers.'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
$tree_access_cacheability->applyTo($output);
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue