File tree Expand file tree Collapse file tree
src/Resolver/TemplateChain Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55### Added
66- Template Filter to sanitize HTML content
77- PHP v8.5 support
8+ - Cache template chains and use cached module paths to improve rendering performance
89
910### Changed
1011- Extension include_content uses HTML sanitizer
Original file line number Diff line number Diff line change 1414class TemplateChainResolver implements TemplateChainResolverInterface
1515{
1616 private array $ lastChildCache = [];
17+ private array $ parentCache = [];
1718
1819 public function __construct (
1920 private TemplateChainBuilderInterface $ templateChainBuilder ,
@@ -23,11 +24,15 @@ public function __construct(
2324
2425 public function getParent (string $ templateName ): string
2526 {
26- $ templateType = $ this ->templateTypeFactory ->createFromTemplateName ($ templateName );
27- return $ this ->templateChainBuilder
28- ->getChain ($ templateType )
29- ->getParent ($ templateType )
30- ->getFullyQualifiedName ();
27+ if (!isset ($ this ->parentCache [$ templateName ])) {
28+ $ templateType = $ this ->templateTypeFactory ->createFromTemplateName ($ templateName );
29+ $ this ->parentCache [$ templateName ] = $ this ->templateChainBuilder
30+ ->getChain ($ templateType )
31+ ->getParent ($ templateType )
32+ ->getFullyQualifiedName ();
33+ }
34+
35+ return $ this ->parentCache [$ templateName ];
3136 }
3237
3338 public function getLastChild (string $ templateName ): string
Original file line number Diff line number Diff line change 1818
1919class TemplateChainSorter implements TemplateChainSorterInterface
2020{
21+ private array $ chainCache = [];
22+
2123 public function __construct (
2224 private SortingConfigurationValidatorInterface $ sortingConfigurationValidator ,
2325 private ShopConfigurationDaoInterface $ shopConfigurationDao ,
@@ -28,11 +30,15 @@ public function __construct(
2830
2931 public function sort (TemplateChain $ unsortedChain , TemplateTypeInterface $ extendedTemplate ): TemplateChain
3032 {
31- $ sortingConfiguration = $ this ->shopConfigurationDao
32- ->get ($ this ->context ->getCurrentShopId ())
33- ->getModuleTemplateExtensionChain ();
33+ $ shopId = $ this ->context ->getCurrentShopId ();
34+
35+ if (!isset ($ this ->chainCache [$ shopId ])) {
36+ $ this ->chainCache [$ shopId ] = $ this ->shopConfigurationDao
37+ ->get ($ shopId )
38+ ->getModuleTemplateExtensionChain ();
39+ }
3440
35- return $ this ->getSortedChain ($ unsortedChain , $ sortingConfiguration , $ extendedTemplate );
41+ return $ this ->getSortedChain ($ unsortedChain , $ this -> chainCache [ $ shopId ] , $ extendedTemplate );
3642 }
3743
3844 private function getSortedChain (
You can’t perform that action at this time.
0 commit comments